实现数字加减

来源:互联网 发布:cpld 软件 编辑:程序博客网 时间:2024/05/28 06:05
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>


</head>
<body>
<div class="spinner">
    <input type="text" readonly="readonly" value="1" id="t1" />
    <div class="arrow"><a onclick="addminus('t1')">+</a><a onclick="addminus('t1', true)">-</a></div>
</div>


<script>
    function addminus(id, add) {
        var t = document.getElementById(id),
v = parseInt(t.value) || 0;
        add ? v++ : v--;
if(v>=0){
        t.value = v;
}
    }
</script>
</body>
</html>
0 0
原创粉丝点击