当您在输入数字时按住向上或向下的按钮时,我正在试图找到触发的JQuery事件。一旦您释放按钮,change事件就会触发,但它不会在按住按钮时逐步触发。如果每次输入中的数字发生变化,我应该使用什么事件来激发它?
发布于 2019-08-24 23:14:30
使用'input'事件
$('[type="number"]').on('input', function(e) {
console.log(e.type)
})Use keyboard arrows or Input's UI arrows:<br>
<input type="number" name="">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
'keypress'事件仅在type=text上工作
$('input').on('keypress', function(e) {
console.log(e.type)
})<input type="text" name="" value="text type">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
https://stackoverflow.com/questions/57642042
复制相似问题