0

How I can get the number of an input type=range slider?

How I can get the number of an input type=range slider with javascript? Thanks for you help :D

5th Jul 2018, 9:04 AM
Henry Steinhauer
Henry Steinhauer - avatar
5 Respostas
+ 1
Hi Henry Steinhauer, The number on a range slider is assigned through the "value" attribute, so you can fetch that like you would any other attribute: getAttribute("value") I hope this helps! :)
5th Jul 2018, 9:31 AM
Janning⭐
Janning⭐ - avatar
+ 1
Expanded example: <input type="range" id="myRange" value="90"> <br> <button onclick="myFunction()">Grab slider value</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myRange").getAttribute("value"); document.getElementById("demo").innerHTML = x; } </script>
5th Jul 2018, 9:33 AM
Janning⭐
Janning⭐ - avatar
+ 1
thanks for your answers and help. I have resolve the problem :D
5th Jul 2018, 9:47 AM
Henry Steinhauer
Henry Steinhauer - avatar
+ 1
Anytime! 👍
5th Jul 2018, 9:48 AM
Janning⭐
Janning⭐ - avatar