Javascript examples for DOM HTML Element:Input Range
The defaultValue property sets or gets the default value of a slider control.
The default value is the value specified in the HTML value attribute.
You can use the defaultValue property to find out whether the value of a slider control have been changed.
Set the defaultValue property with the following Values
Value | Description |
---|---|
value | Sets the default value of the slider control |
A String, representing the default value of the slider control
The following code shows how to get the default value of a slider control:
<!DOCTYPE html> <html> <body> Points: <input type="range" id="myRange" value="20"> <button type="button" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w. ja v a2 s . co m*/ var x = document.getElementById("myRange"); var defaultVal = x.defaultValue; document.getElementById("demo").innerHTML = defaultVal; } </script> </body> </html>