<input id="min_${menu.id }" class="min" type="button" value="-" onclick="javascript:min(${menu.id });" />
<script type="text/javascript">
$(function(){
var tot = 0;
function min(id){
    alert(id);
var price = $("#price_"+id).html();
if(t.val() > 0){
    t.val(parseInt(t.val())-1);
    tot = tot-parseInt(price);
    alert(tot);
}
 }
function add(id){
     alert(id);
    var price = $("#price_"+id).html();
    tot = tot + parseInt(price);
    alert(tot);
    if(tot > 15){
     alert("总价超额  ");
     return false;
    }
    t.val(parseInt(t.val())+1);
}
});
</script>为什么点了以后出错 

解决方案 »

  1.   

    alert一下错误点的信息,然后发出来。
      

  2.   

    你调用的是min方法,你把你的
    function min(id){
         alert(id);
     var price = $("#price_"+id).html();
     if(t.val() > 0){
         t.val(parseInt(t.val())-1);
         tot = tot-parseInt(price);
         alert(tot);
     }
    方法从$(function(){}里面拿出来试试
    可以把你的错误信息贴出来。
      

  3.   

    if(t.val() > 0){
        t.val(parseInt(t.val())-1);
        tot = tot-parseInt(price);
        alert(tot);
    }
    你的t是啥对象?