Javascript DOM HTML Input Color type Property get

Introduction

Find out the type of the color picker:

var x = document.getElementById("myColor").type;

Click button to find out the type the color picker.

View 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  a va 2 s.co  m*/
  var x = document.getElementById("myColor").type;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The type property returns the type of the color picker.

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




PreviousNext

Related