Input Color type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Color

Description

The type property returns the type of form element.

For a color picker this property always returns "color".

Return Value

A String, representing the type of form element the color picker is

The following code shows how to check which type of form element the color picker is:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

A color picker: <input type="color" id="myColor">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from  w  w w .j  av a2s . c  o  m*/
    var x = document.getElementById("myColor").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials