The autofocus
property sets or gets
whether a week field should automatically get focus when the page loads.
autofocus |
Yes | No | No | Yes | Yes |
Return the autofocus property.
var v = weekObject.autofocus
Set the autofocus property.
weekObject.autofocus=true|false
Value | Description |
---|---|
true|false | Set whether a week field should get focus when the page loads, or not
|
A Boolean type value, true if the week field automatically gets focus when the page loads, otherwise false.
The following code shows how to check if a week field can automatically get focus upon page load.
<!DOCTYPE html>
<html>
<body>
<!--from w w w . ja va2 s .c o m-->
<input type="week" id="myWeek" autofocus>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myWeek").autofocus;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: