您的位置:首页 > 其它

实现数字加减

2016-12-08 14:31 176 查看
<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: