<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>动态改变购买数量</title>
<link href="css/detail.css" rel="stylesheet" />
<script>
function numcheck()
{
var w=document.getElementById("buycount").value;
var reg=/^\-[1-9][0-9]*$/;
if(reg.test(w))
{
return true;
}
else{
return false;
}
}
//编写函数实现数量增加
function addBuynum()
{
var num=document.getElementById('buycount');
if(num)
{
return;
}
num++;
document.getElementById().innerHTMLdocument.getElementById('buycount').innerHTML=num;
$('#buycount').val(num);
}
</script>
</head>
<body>
<div class="prod-buychoose">
<dl class="pProps" id="choosenum">
<dt>购买数量: </dt>
<dd id="choose-num"><a class="reduce" id="reduce1" ></a>
<input id="buycount" value="1" onclick="numcheck()" />
<a class="add" id="add1" onclick="addBuynum()"></a>
</dd>
</dl>
</div>
</body>
</html>
求快看看 实现数量增加部分有什么问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- Null_Reference 2022-04-22 14:56关注
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>动态改变购买数量</title> <link href="css/detail.css" rel="stylesheet" /> <script> function numcheck() { var w=document.getElementById("buycount").value; var reg=/^\-[1-9][0-9]*$/; if(reg.test(w)) { return true; } else{ return false; } } //编写函数实现数量增加 function addBuynum() { var num=document.getElementById('buycount').value; if(!num) { return; } num++; document.getElementById('buycount').value=num; } </script> </head> <body> <div class="prod-buychoose"> <dl class="pProps" id="choosenum"> <dt>购买数量: </dt> <dd id="choose-num"><a class="reduce" id="reduce1" ></a> <input id="buycount" value="1" onclick="numcheck()" /> <a class="add" id="add1" onclick="addBuynum()">增加</a> </dd> </dl> </div> </body> </html>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
- ¥20 关于URL获取的参数,无法执行二选一查询
- ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
- ¥15 marlin编译错误,如何解决?
- ¥15 有偿四位数,节约算法和扫描算法
- ¥15 VUE项目怎么运行,系统打不开
- ¥50 pointpillars等目标检测算法怎么融合注意力机制
- ¥20 Vs code Mac系统 PHP Debug调试环境配置
- ¥60 大一项目课,微信小程序
- ¥15 求视频摘要youtube和ovp数据集