![](/img/trans.png)
[英]Show notification that value is max on arrow up click on input type="number"
[英]Input type number should start again from min value with up arrow and max value with down arrow
我有数字输入,
<input type="number" name="start" id="start" value="0" min="0" max="24" />
所以,我想要的功能就像当我点击向上箭头直到最大值(这里是24)到达之后它应该从0再次开始,同样当达到极限直到最小值(0这里)用向下箭头,之后它应该从24开始。
同样应该使用keyup和keydown箭头。
任何帮助,将不胜感激!
这样的事情
function myFunction(){ if(document.getElementById("start").value == 25){ document.getElementById("start").value = 0; } }
<input type="number" name="start" id="start" value="0" min="0" max="25" onchange="myFunction()" />
如果你想在数字命中0时做同样的事情,那么使用这个代码:
function myFunction(){ if(document.getElementById("start").value == 25){ document.getElementById("start").value = 0; } if(document.getElementById("start").value == -1){ document.getElementById("start").value = 24; } }
<input type="number" name="start" id="start" value="0" min="-1" max="25" onchange="myFunction()" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.