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