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