Jquery, can not delete newly created li elements
<p>As a uni project i am making a shopping cart, so far you can add products to the cart, and if you refresh the page, you can delete items from the cart.</p>

<p>But when the item is added to the basket, you can not delete it from the cart without first refreshing the browser. Why is that?</p>

<p>this is my delete item form cart funtion</p>

<pre><code>    $('.del').on("click",function(){
    var id= this.id;
    var productId = $('#productId-'+id).text();
    var productPrice = $('#price-'+id).text();
    var total = $('#total').text();
    var newPrice = (parseFloat(total) - parseFloat(productPrice)).toFixed(2);
    var dataString = 'id='+ id;
    cartSize--;

    $('#total').html(newPrice);     
    $("#cart-"+id).slideUp('slow', function() {$(this).remove();});

    $.ajax({
        type: "POST",
        url: "resources/del.php",
        data: dataString,
        cache: false,
        success: function(html){
            $('#added-'+productId).fadeOut('Fast');
            $('#product-'+productId).delay(600).fadeIn('Fast');

            if(cartSize == 0){
                $('#noItems').fadeIn('Fast');
                $('#mainCart').fadeOut('Fast');     
            }
        }
    });
    return false;   

});
</code></pre>

<p>});</p>

<p>and heres my add to cart function:</p>

<pre><code>     $('.addToCart').click(function(){
    var id = this.id;
    var price = parseFloat($('#priceAdd-'+id).val()).toFixed(2);;
    var name = $('#name-'+id).val();
    var total =(parseFloat($('#total').text())+parseFloat(price)).toFixed(2);
    cartSize++;

    $('#product-'+id).fadeOut('fast');
    $('#added-'+id).delay(500).fadeIn('fast');

    $.ajax({
        type: "POST",
        url: 'resources/addToCart.php',
        data: { itemId: id , name: name, price: price},
        cache: false,
        success: function(html){
            $("ol").append(html).slideDown("slow");
            $('#noItems').fadeOut('fast');
            $('#total').html(total);
            $('#mainCart').fadeIn('fast');
        }
    });
});
</code></pre>

<p>Any input would be greatly appreciated,</p>

<p>Thanks</p>
