Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solution() {
- let isMatch = true;
- $('button').on('click', function(){
- let div = $('<div>');
- div.addClass('gift');
- let img = $('<img>');
- img.attr('src','gift.png');
- div.append(img);
- let inputh2 = $('#toyType').val();
- $('#toyType').val('')
- if(inputh2==''){isMatch=false;}
- let h2 = $('<h2>');
- h2.text(inputh2);
- let inputp = $('#toyDescription').val();
- $('#toyDescription').val('')
- let p = $('<p>');
- p.text(inputp);
- let inputPrice = $('#toyPrice').val();
- $('#toyPrice').val('')
- if(inputPrice.match(/^\d+\.?\d+$/g)==null){isMatch=false;}
- if(inputp==''){isMatch=false;}
- let button = $('<button>').on('click',function(){
- div.remove();
- });
- button.text(inputPrice);
- if(isMatch==false){return;}
- div.append(h2);
- div.append(p);
- div.append(button);
- $('#christmasGiftShop').append(div);
- let title = $('#christmasGiftShop').find('h2').text()
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment