Get the default value of a color picker:
var x = document.getElementById("myColor").defaultValue
Click button to display the default value of the color picker.
<!DOCTYPE html> <html> <body> A color picker: <input type="color" id="myColor" value="#ff0080"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//w ww . ja v a2 s . c o m var x = document.getElementById("myColor").defaultValue; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The defaultValue
property sets or gets the default value of a color picker.
The default value is the value set in the HTML value attribute.
defaultValue
contains the default value, while value contains the current value.
If there are no changes, defaultValue
and value is the same.
The defaultValue
property accepts and returns a String value.