input左减右加

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">

<style>



</style>
</head>
<body>
<input id="min" name="" type="button" value="-" />
<input id="text_box" name="goodnum" type="text" value="0" style="width:100px;" />
<input id="add" name="" type="button" value="+" />

<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(function(){
var t = $("#text_box");
$("#add").click(function(){
t.val(parseInt(t.val())+1)
setTotal();
})
$("#min").click(function(){
t.val(parseInt(t.val())-1)
setTotal();
})
function setTotal(){
var tt = $("#text_box").val();
var pbinfoid=$("#pbinfoid").val();
if(tt<=0){
alert('输入的值错误!');
t.val(parseInt(t.val())+1)
}
}

})
</script>
</body>
</html>

posted on 2017-10-30 20:46  芸芸众生!  阅读(371)  评论(0编辑  收藏  举报