How I can get the number of an input type=range slider? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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 Answers
6th Aug 2018, 2:56 PM
CalviÕ²
CalviÕ² - avatar
+ 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