Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Book Generator</title>
- <script src="https://code.jquery.com/jquery-3.1.0.min.js"
- integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s="
- crossorigin="anonymous"></script>
- </head>
- <body>
- <div id="wrapper">
- </div>
- <script>
- window.onload = function () {
- createBook("#wrapper", 'Alice in Wonderland', 'Lewis Carroll', 1111, 'megamega', 'wtf', 1234);
- }
- </script>
- <script>
- function createBook(selector) {
- let mainDiv = selector
- for (let i = 1; i < arguments.length; i += 3) {
- let counter = 1
- let kniga = "book" + counter
- $(mainDiv).append('<div id = kniga style="border: medium none"></div>')
- $('#kniga').append('<p class="title"></p>')
- $('#kniga').append('<p class="author"></p>')
- $('#kniga').append('<p class="isbn"></p>')
- $('.title').append(arguments[i])
- $('.author').append(arguments[i + 1])
- $('.isbn').append(arguments[i + 2])
- $('#kniga').append($('<button id="sel">Select</button>'))
- $('#kniga').append($('<button id="des">Deselect</button>'))
- $('#sel').click(selectItem)
- $('#des').click(deselect)
- $(mainDiv).append('</div>')
- counter++
- }
- }
- function selectItem() {
- document.getElementById("kniga").style.border = "2px solid blue"
- }
- function deselect() {
- document.getElementById("book").style.border = "none"
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement