Get Input Color - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Color

Introduction

The Input object represents an HTML <input> element with type="color".

You can access an <input> element with type="color" by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Select your favorite color: <input type="color" id="myColor">

<button onclick="myFunction()">get the color of the color picker</button>

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

<script>
function myFunction() {/* ww  w.j  a  va 2 s .com*/
    var x = document.getElementById("myColor").value;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials