The autofocus
property sets or gets whether a color picker can
automatically get focus when the page loads.
autofocus |
Yes | No | Yes | No | Yes |
Return the autofocus property.
var v = colorObject.autofocus
Set the autofocus property.
colorObject.autofocus=true|false
Value | Description |
---|---|
true|false | Set whether a color picker can get focus when the page loads
|
A Boolean type value, true if the color picker can automatically get focus when the page loads, otherwise it returns false.
The following code shows how to get if a color picker automatically gets focus.
<!DOCTYPE html>
<html>
<body>
<!-- w ww . jav a2s.c o m-->
A color picker: <input type="color" id="myColor" autofocus>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myColor").autofocus;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: