<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>为什么点了以后出错
<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>为什么点了以后出错
解决方案 »
- 有没有什么好的论坛博客系统介绍下哈(JAVA开发的)
- 为什么我的JSP不能打开SQLserver2000数据库(新手的菜鸟问题)
- 给大家拜年了,顺便问一个报表实现的问题,大家帮帮忙呀!
- 求助关于struts标题显示长度的问题
- 能否这样做?(变量定义问题)
- Java中的问题,不明白这样写是什么意思?各位大神可以解释一下么?代码如下:
- IKAnalyzer.cfg.xml 配置扩展词典
- 硬盘怎样恢复?
- 请教JSWDK高手???
- 求救:jsp和servlet中如何实现upload文件?
- SSh hibernate 执行hql报错:org.springframework.orm.hibernate3.HibernateQueryException
- [求助]springmvc+mybatis的问题
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(){}里面拿出来试试
可以把你的错误信息贴出来。
t.val(parseInt(t.val())-1);
tot = tot-parseInt(price);
alert(tot);
}
你的t是啥对象?