jquery controlling shopping cart
<p>I am using the follow to build a php shopping cart:-</p>

<pre><code>    while loop of a foreach {
    &lt;tr class="row_display&lt;?=$key;?&gt;"&gt;
                &lt;td&gt;&lt;?=$product_name;?&gt;&lt;/td&gt;
                &lt;td&gt;
                &lt;select name="qty" class="quantity"&gt;
                &lt;?php
                for ($i=1; $i&lt;=1000;$i++)
                {?&gt;
                &lt;option value="&lt;?=$i?&gt;"&gt;&lt;?=$i?&gt;&lt;/option&gt;
                &lt;?php }?&gt;
                &lt;/select&gt;
                &lt;/td&gt;
                &lt;td&gt;&lt;input type="hidden" class="unit_price" value="&lt;?=number_format($product_price,2);?&gt;"/&gt;$&lt;?=number_format($product_price,2);?&gt;&lt;/td&gt;
                &lt;td&gt;&lt;span class="sub_total"&gt;$&lt;?=$product_price?&gt;&lt;/span&gt;&lt;/td&gt;
                &lt;td&gt;
                &lt;span onclick="delete_item(&lt;?=$key;?&gt;)"&gt;&lt;/span&gt;
                Del&lt;/span&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
                }//while loop

&lt;script&gt;
    function delete_item(val){
    $(".row_display"+item_id+"").addClass("display_none");
    update_sub_total();
    }
&lt;/script&gt;
</code></pre>

<p>Although I can add class to the tr and make it display none, I found the total number at the end still did not update. How can I destroy the row value as well? </p>

<pre><code>&lt;script&gt;
function update_sub_total(){
    var total = 0;
    $(".sub_total").each(function(){
        var qty = Number($(this).parent().parent().find(".quantity").val());
        var unit_price = Number($(this).parent().parent().find(".unit_price").val());
        var sub_total = Math.round(qty * unit_price).toFixed(2);
        var sub_total_final = number_format(sub_total, 2);
        total += qty * unit_price;
        $(this).html('$'+sub_total_final);
    });

    var total_final = number_format(total, 2);
    $(".total").html("$"+total_final);
}
&lt;/script&gt;
</code></pre>
