html - Product list with jquery. Method remove() -


it simple product list. use jquery. have problem. remove() dont work , elements of list dont remove. dont understand why. me please, , sorry english). code.

html

<div class="container">    <h1>product list</h1>    <input type="text" name="newproduct" id="newproduct" placeholder="enter 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('http://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 , elements of list dont remove. dont understand why. me please, , sorry english)

live doesn't support jquery version. live deprecated @ version 1.7 @ removed @ version 1.9. when use live @ version >=1.9, give error (check console).

see there: http://api.jquery.com/live/


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -