Product list with jquery. Method remove()

It is my simple product list. I use jquery. But i have some problem. Remove() dont work and elements of list dont remove. I dont understand why.
Help me please, and sorry for my english). It is my code.

HTML

<div class="container">
   <h1>Product List</h1>
   <input type="text" name="newProduct" id="newProduct" placeholder="Enter your product here"/>
   <ul id="productList"></ul>
</div>  

CSS code

* {
box-sizing:border-box;
}
body {
font-family: Tahoma, sans-serif;
}
.container {
    margin:0 auto;
    width:600px;
}
h1, #newProduct {
    text-align: center;
    width:598px;
}
 #newProduct {
    border:1px solid #999;
    padding: 20px;
    font-size: 28px;
    box-shadow: 0px 0px 3px #888;
}
#productList {
    list-style: none;
    padding-left:0;
    background-color: #F2F2F2;
}
.product {
    padding: 15px 0px 15px 40px;
    margin: 10px;
    position: relative; 
    font-size: 24px;
    box-shadow: 2px 2px 3px #848484;
    background-color: #fff;
    cursor: pointer;
}
.product:hover {
    background-color: #F2F2F2;
}
.doneProduct {
    margin-right: 40px;
}
.remove {
    background-image:    url('https://www.imageup.ru/img200/2152803/delete_ico.png');
    background-position: 0 0;
    width:30px;
    height: 30px;
    position: absolute;
    right: 20px;
    top:13px;   
    display: none;
}
.remove:hover {
    background-position: -34px 0px;
}
.product:hover> .remove {
    display: block;
}

jquery

function addNewProduct(e) {
    if(e.keyCode == 13) {
            var toAdd = $('input[name=newProduct]').val();
            $('#productList').append('<li class="product"> <input     type="checkbox" class="doneProduct"/>'+toAdd+'<div class="remove"></div><li/>');
            $('#newProduct').val('');
            e.preventDefault();
        };
};

function deleteProduct() {
    $(this).parent().remove();
};

$(function() {
    $("#newProduct").on('keypress', addNewProduct);
    $(".remove").live('click', deleteProduct);
}) ;

But remove() dont work and elements of list dont remove. I dont understand why.
Help me please, and sorry for my english)


Source: html

Leave a Reply