Advertisement
fbinnzhivko

Untitled

Oct 24th, 2016
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function createBook() {
  2.     let id = 1;
  3.     return function (selector, title, author, isbn) {
  4.         let text = '';
  5.         let divid = 'book' + id;
  6.         text +='<div id="' + divid + '" style="border: medium none;">';
  7.         text += '<p class="title">' + title + '</p>';
  8.         text += '<p class="author">' + author + '</p>';
  9.         text += '<p class="isbn">' + isbn + '</p>';
  10.         text += '<button id="select">Select</button>';
  11.         text += '<button id="deselect">Deselect</button>';
  12.         text += '</div>';
  13.         id++;
  14.         $(selector).html(text);
  15.  
  16.         let selectButton = $('#select');
  17.         let deselectButton = $('button:contains("Deselect")');
  18.         $('#select').click(function (event) {
  19.             $('#'+divid).css("border", "2px solid blue")
  20.         });
  21.         $('#deselect').click(function (event) {
  22.             $('#'+divid).css("border", "none")
  23.         });
  24.     }
  25. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement