Apparently Chrome and Safari are wrong: onchange
should only be triggered when the user releases the mouse.
(显然Chrome和Safari是错误的:只有在用户释放鼠标时才会触发onchange
。)
To get continuous updates, you should use the oninput
event, which will capture live updates in Firefox, Safari and Chrome, both from the mouse and the keyboard.(要获得持续更新,您应该使用oninput
事件,它将通过鼠标和键盘捕获Firefox,Safari和Chrome中的实时更新。)
However, oninput
is not supported in IE10, so your best bet is to combine the two event handlers, like this:
(但是,IE10不支持oninput
,所以最好的办法是组合两个事件处理程序,如下所示:)
<span id="valBox"></span>
<input type="range" min="5" max="10" step="1"
oninput="showVal(this.value)" onchange="showVal(this.value)">
Check out this Bugzilla thread for more information.
(查看此Bugzilla线程以获取更多信息。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…