Advertisement
Guest User

asd

a guest
Mar 13th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.76 KB | None | 0 0
  1. function solution() {
  2.     $("#fields button").on("click",function(){
  3.         let toyTypeVal = $("#toyType").val();
  4.         let toyPriceVal = $("#toyPrice").val();
  5.         let toyDescriptionVal = $("#toyDescription").val();
  6.         if(toyTypeVal.trim() && $.isNumeric(toyPriceVal) && toyDescriptionVal && toyDescriptionVal.length >= 50){
  7.             let div = $("<div>",{
  8.                 class: "gift"
  9.             });
  10.             let img = $("<img>",{
  11.                 src: "gift.png"
  12.             });
  13.             let h2 = $(`<h2>${toyTypeVal}</h2>`);
  14.             let p = $(`<p>${toyDescriptionVal}</p>`);
  15.             let button = $("<button>",{
  16.                 text: `Buy it for $${toyPriceVal}`
  17.             });
  18.             div.append(img).append(h2).append(p).append(button);
  19.             let section = $("#christmasGiftShop");
  20.             section.append(div);
  21.             button.on("click",() => div.remove());
  22.            
  23.         }
  24.     })
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement