
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input Color type Property
The HTML DOM Input Color type property returns/sets type of Input Color.
Syntax
Following is the syntax −
- Returning string value
inputColorObject.type
- Setting type to string value
inputColorObject.type = stringValue
String Values
Here, “stringValue” can be the following −
stringValue | Details |
---|---|
Color | It defines that input type is color |
Radio | It defines that input type is radio |
Text | It defines that input type is text |
Example
Let us see an example of Input Color type property −
<!DOCTYPE html> <html> <head> <title>Input Color Type</title> </head> <body> <form id="formForColorsInput"> Color Picker: <input type="color" id="Color" name="primaryColor" value="#0000ff"> </form> <button onclick="changeNameValue()">Get type & change to text</button> <div id="divDisplay"></div> <script> var inputColor = document.getElementById("Color"); var divDisplay = document.getElementById("divDisplay"); divDisplay.textContent = 'Type of Input: '+inputColor.type; function changeNameValue() { if(inputColor.type == 'color'){ var defaultColor = inputColor.defaultValue; inputColor.type = 'text'; inputColor.value = defaultColor; divDisplay.textContent = 'Name of color input: '+inputColor.type; } } </script> </body> </html>
Output
This will produce the following output −
Before clicking ‘Get type & change to text’ button −
After clicking ‘Get type & change to text’ button −
- Related Articles
- HTML DOM Input Color autofocus Property
- HTML DOM Input Color defaultValue Property
- HTML DOM Input Color disabled Property
- HTML DOM Input Color form Property
- HTML DOM Input Color name Property
- HTML DOM Input Color value Property
- HTML DOM Input Time type Property
- HTML DOM Input URL type Property
- HTML DOM Input Week type Property
- HTML DOM Input Number type Property
- HTML DOM Input Reset type property
- HTML DOM Input Search type property
- HTML DOM Input Submit type Property
- HTML DOM Input Password type property
- HTML DOM Input Radio type property

Advertisements