Slider: How to get current slider value?

Created on 20 Apr 2016  路  6Comments  路  Source: react-component/slider

How to get current slider value?

currentValue = document.getElementById( WHAT_ID? )

Or is there a special method?

Most helpful comment

In case somebody is still wondering, onChange takes the bounds/value as an argument.

All 6 comments

@benjycui
What was that with smart questions? I can offer you to try smart answers.

I know about onChange method all right.
Now imagine, please, a situation when you need to get current slider value from within other component. Not BY MOVING slider and calling onChange but from stopped slider. How can I do it? Get value without calling onChange?

In case somebody is still wondering, onChange takes the bounds/value as an argument.

It's funny to come across these replies that completely miss what OP was asking. For anyone else who is looking for how to get the input value from the slider in the way that OP was describing, use a react reference, then look in the childnodes object for the input value and then reference like so: player.seekBarRef().current.childNodes[2].value.

I was also amused by reading the non-thinking-about-question-answers... also wanted to read out the value of the slider in the moment I changed another React-Switch.
Of course I could build up a reference but I also found the value of my reactSlider to be written simply in the element.innerText-variable... but I'm not sure if that is always the case :)

Was this page helpful?
0 / 5 - 0 ratings