Advertisement
Guest User

Untitled

a guest
Jan 6th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Book Generator</title>
  6. <script src="https://code.jquery.com/jquery-3.1.0.min.js"
  7. integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s="
  8. crossorigin="anonymous"></script>
  9. </head>
  10. <body>
  11. <div id="wrapper">
  12.  
  13. </div>
  14. <script>
  15. window.onload = function () {
  16. createBook("#wrapper", 'Alice in Wonderland', 'Lewis Carroll', 1111, 'megamega', 'wtf', 1234);
  17. }
  18. </script>
  19. <script>
  20. function createBook(selector) {
  21. let mainDiv = selector
  22. for (let i = 1; i < arguments.length; i += 3) {
  23. let counter = 1
  24. let kniga = "book" + counter
  25. $(mainDiv).append('<div id = kniga style="border: medium none"></div>')
  26. $('#kniga').append('<p class="title"></p>')
  27. $('#kniga').append('<p class="author"></p>')
  28. $('#kniga').append('<p class="isbn"></p>')
  29. $('.title').append(arguments[i])
  30. $('.author').append(arguments[i + 1])
  31. $('.isbn').append(arguments[i + 2])
  32. $('#kniga').append($('<button id="sel">Select</button>'))
  33. $('#kniga').append($('<button id="des">Deselect</button>'))
  34. $('#sel').click(selectItem)
  35. $('#des').click(deselect)
  36. $(mainDiv).append('</div>')
  37. counter++
  38. }
  39.  
  40. }
  41. function selectItem() {
  42. document.getElementById("kniga").style.border = "2px solid blue"
  43. }
  44. function deselect() {
  45. document.getElementById("book").style.border = "none"
  46.  
  47. }
  48. </script>
  49. </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement