Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Input Color defaultValue Property
The HTML DOM Input Color defaultValue property sets/returns the default value corresponding to a color. It may or may not be same as value attribute.
Syntax
Following is the syntax −
- Returning string value
inputColorObject.defaultValue
- Setting defaultValue to string
inputColorObject.defaultValue = ‘string’
Boolean Value
Here, “string” can be the following −
| booleanValue |
Details |
|---|---|
| #000000 - #ffffff |
It defines that input color can have a default value between the defined range |
Example
Let us see an example of Input Color defaultValue property −
<!DOCTYPE html>
<html>
<head>
<title>Input Color Default Value</title>
</head>
<body>
<form>
Color Picker: <input type="color" id="Color" value="#00cc00">
</form>
<button onclick="getDefaultValue()">Get Default Value</button>
<div id="divDisplay"></div>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputColor = document.getElementById("Color");
function getDefaultValue() {
divDisplay.textContent = 'Default Color: '+inputColor.defaultValue;
}
</script>
</body>
</html>
Output
This will produce the following output −
Before clicking ‘Get Default Value’ button −

After clicking ‘Get Default Value’ button −

Advertisements