Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solution() {
- $("#fields button").on("click",function(){
- let toyTypeVal = $("#toyType").val();
- let toyPriceVal = $("#toyPrice").val();
- let toyDescriptionVal = $("#toyDescription").val();
- if(toyTypeVal.trim() && $.isNumeric(toyPriceVal) && toyDescriptionVal && toyDescriptionVal.length >= 50){
- let div = $("<div>",{
- class: "gift"
- });
- let img = $("<img>",{
- src: "gift.png"
- });
- let h2 = $(`<h2>${toyTypeVal}</h2>`);
- let p = $(`<p>${toyDescriptionVal}</p>`);
- let button = $("<button>",{
- text: `Buy it for $${toyPriceVal}`
- });
- div.append(img).append(h2).append(p).append(button);
- let section = $("#christmasGiftShop");
- section.append(div);
- button.on("click",() => div.remove());
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement