The autofocus
property sets or gets
whether a slider control can auto focus when the page loads.
autofocus |
Yes | 10.0 | Yes | Yes | Yes |
Return the autofocus property.
var v = rangeObject.autofocus
Set the autofocus property.
rangeObject.autofocus=true|false
Value | Description |
---|---|
true|false | Set whether a slider control can auto focus when the page loads
|
A Boolean type value, true if the slider control automatically gets focus when the page loads, otherwise false.
The following code shows how to check if a slider control can auto focus upon page load.
<!DOCTYPE html>
<html>
<body>
<input type="range" id="myRange" autofocus>
<button onclick="myFunction()">test</button>
<!--from w w w . j a v a2 s . c om-->
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myRange").autofocus;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: