<html>
<head>
<script src="/jquery/jquery-1.11.1.min.js">
</script>
<script>
$(document).ready(function(){
$("#add").click(function(){
var sum = $("#sum").val()
var result = Number(sum)+1
$("#sum").val(result)
})
$("#down").click(function(){
var sum = $("#sum").val()
var result = Number(sum)-1
$("#sum").val(result)
})
})
</script>
</head>
<body>
<input id='sum' value='0'>
<p id='add'>添加</p>
<p id='down'>减少</p>
</body>
</html>
跟这个类似
这个一般用JS来实现,大致应该是这样<!--js函数大致如下 -->
function del(){
var count = document.getElementById("count").value
count--
document.getElementById("count").value = count
if(count<=1){
document.getElementById("del0").style.display = block
document.getElementById("del1").style.display = none
}
if(count <total){//假定total是库存量
document.getElementById("add0").style.display = block
document.getElementById("add1").style.display = none
}
}
function add(){
//......和del方法类似
}
<!-- 页面处代码大致如下 -->
<img id="del1"
src="...." onclick="del()" style="dispaly:block">
<img id="del0"
src="...." style="display:none">
<input type="text" id="count" readonly>1 </input>
<img id="add1"
src="...." onclick="add()" style="dispaly:block">
<img id="add0"
src="...." style="dispaly:none">
很久没写代码了,估计疏漏不少,不过大致是这样的思路
var each = $(".sys_item_mktprice").text()var total = $(".sys_item_price")
$(":text.sys_count_input").keyup(function(){
var me = $(this), txt = parseFloat(me.val())
total.text(txt * each)
})
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)