+ 1

How can I set an event listener for a slider/range input?

As title - I want to update/run the function each time the slider is changed, without a confirm button. Previously I did this on the HTML side with a onchange=“function(this.value)” argument but this was discouraged against so I am now trying to move to a JS sided approach. I was able to make the button listeners work but I’m stuck at getting the slider to update with its event listener. https://code.sololearn.com/W1dspZEP80Pt/?ref=app

10th Jul 2020, 3:17 PM
Pxnt
Pxnt - avatar
3 Answers
+ 1
OK.. https://code.sololearn.com/WQWk187UMvn9/?ref=app Specify the function name, you are calling the function when you put the arg. You can access the button with 'this' keyword.
10th Jul 2020, 3:44 PM
Arnesh
Arnesh - avatar
0
Arnesh thanks, but this isn’t what i’m looking for... the core issue is that i am trying to move away from js in the html file as this is considered bad practice. i had the onchange attribute in there beforehand
10th Jul 2020, 3:33 PM
Pxnt
Pxnt - avatar