JS实时滑块?

时间:2015-12-27 17:09:22

标签: javascript function slider

<input type="range" id="slider"> document.getElementById('slider').addEventListener("change", function(){})
此代码等待,直到您放开滑块输入值。如何在函数发生时实时更改?


I want the box to chanmge as I move the slider [JS FIDDLE]

1 个答案:

答案 0 :(得分:1)

不要收听change个事件,而是听input

document.getElementById('slider').addEventListener("input", function(){})

https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/oninput