您的位置:首页 > Web前端 > CSS

number类型的input样式修改及绑定左右按钮

2020-07-12 17:12 1251 查看
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>Jay Skript And The Domsters</title>
<style type="text/css">
*{border:none;margin:0px;padding:0px;}
.number{ padding: 36px 0 28px;width:400px;margin:auto}
.minus{width: 30px; height: 30px; text-align: center;border: solid 1px #eaeaea; background: #f5f5f5; color: #9e9e9e;}
.numbox{border-top: solid 1px #eaeaea; border-bottom: solid 1px #eaeaea; height: 28px; width:60px; color: #333333; margin-left:-8px; text-align: center; background: transparent;}
.plus { margin-left: -8px;}
</style>
</head>
<body >
<div class="number">
购买数量:
<div class="mui-numbox">
<button class="minus" type="button" οnclick="opera('val', false);">-</button>
<input class="numbox" type="number" id="val" value="0"/>
<button class="minus plus" type="button" οnclick="opera('val', true);">+</button>
人次
</div>

<script type="text/javascript">
function opera(x, y) {
var rs = new Number(document.getElementById(x).value);

if (y) {
document.getElementById(x).value = rs + 1;
} else if( rs >0) {
document.getElementById(x).value = rs - 1;
}

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

  

转载于:https://www.cnblogs.com/renewload/p/11227302.html

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: