Javascript Reference - HTML DOM Input Color type Property








The type property returns type of the color picker.

For a color picker this property will always return "color".

Browser Support

type Yes No Yes No Yes

Syntax

var v = colorObject.type 

Return Value

A String type value representing the type of the color picker.





Example

The following code shows how to get the type of the color picker.


<!DOCTYPE html>
<html>
<body>
<!--from ww w.  j a va2 s. c  o  m-->
A color picker: <input type="color" id="myColor">
<button onclick="myFunction()">test</button>
<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myColor").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: