Javascript Chrome(OS X)数字输入元素值更改并不总是发出或触发回调
我发现GoogleChrome输入元素并不总是发送更改事件,或者调用onChangeHander。它在Firefox中运行良好,但在Chrome中不起作用。这个最基本的例子说明了问题: JS: HTML: 仍然不知道如何在没有jQuery的情况下工作。使用Javascript Chrome(OS X)数字输入元素值更改并不总是发出或触发回调,javascript,google-chrome,Javascript,Google Chrome,我发现GoogleChrome输入元素并不总是发送更改事件,或者调用onChangeHander。它在Firefox中运行良好,但在Chrome中不起作用。这个最基本的例子说明了问题: JS: HTML: 仍然不知道如何在没有jQuery的情况下工作。使用.addEventListener('input',function(e){…?document.getElementById('test')。addEventListener('input',function(e){console.log('
.addEventListener('input',function(e){…
?document.getElementById('test')。addEventListener('input',function(e){console.log('works');});
诸如此类?它对我不起作用。给你:
function onChange() {
console.log(document.getElementById('test').value); // Doesn't always get called.
}
<input id="test" type="number" max="99" min="9" size="2" onchange="onChange()">
$("#test").on("input change", function() {
console.log('change:', this.value);
});