jQuery。input type=“number”标签,有两个按钮,点击分别是数字加减100,当数字为0时,减法的按钮失效怎么做;
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title></title> <style> input::-webkit-outer-spin-button, input::-webkit-inner-spin-button{ -webkit-appearance: none !important; margin: 0; } </style> </head> <body> <div class="input-group " style="text-align: center;margin-top:16px;margin-left: -7px;position: relative;background-color:#fff;"> <span class="content-icon-item-1" style="border: 1px solid #999;padding: 14px 9px 11px 12px;text-align: center"><img src="/mobile/images/Symbol-1.png" width="16" height="7"> </span> <input type="number" id="invest-number" placeholder="请输入投资金额" style="width: 60%; height: 44px;margin-top:-6px;"/> <span class="content-icon-item-2" style="border: 1px solid #999 ;margin-left:-5px;padding: 14px 12px 11px 14px;"><img src="/mobile/images/symbol-2.png" width="16" height="16"> </span> </div> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script> <script> $(function(){ var num = 0; var totalnum= 0; $('.content-icon-item-2').click(function(){ var num = parseInt($('#invest-number').val()); totalnum = num + 100; $('#invest-number').val(totalnum); }); $(".content-icon-item-1").click(function(){ var num = parseInt($('#invest-number').val()); totalnum = num - 100; $('#invest-number').val(totalnum); }) $('#invest-number').val(); }); </script> </body> </html>
现在点击后可以出现负数,我想要调整为,数值为0,减法就失效
回夢
相关分类