//W3C/1. Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
jQuery實現購物車多物品數量的加減總價計算 <script> <BR>$(function(){ <BR>$(".add").click(function (){ <BR>var t=$(this).parent().find('input[class*=text_box]'); <BR>t.val(parseInt(t.val()) 1) <BR>setTotal(); <BR>}) <BR>$(".min").click(function(){ <BR>var t=$(this).parent().find('input[class*= text_box]'); <BR>t.val(parseInt(t.val())-1) <BR>if(parseInt(t.val())<0){ <BR>t.val(0); <BR>} <BR>setTotal(); <BR>}) <BR>function setTotal(){ <BR>var s=0; <BR>$("#tab td").each(function(){each(function(){each <BR>s =parseInt($(this).find('input[class*=text_box]').val())*parseFloat($(this).find('span[class*=price]'). text()); <BR>}); <BR>$("#total").html(s.toFixed(2)); <BR>} <BR>setTotal(); <br><br>} ) <BR></script>
總價: