Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Input Week autofocus Property
The Input Week autofocus property sets/returns whether Input Week is focused upon initial page load.
Syntax
Following is the syntax −
- Returning boolean value - true/false
inputWeekObject.autofocus
- Setting autofocus to booleanValue
inputWeekObject.autofocus = booleanValue
Boolean Values
Here, “booleanValue” can be the following −
| booleanValue |
Details |
|---|---|
| True |
It defines that input will be autofocused on page load. |
| False |
It is the default value and input is not autofocused. |
Example
Let us see an example for Input Week autofocus property −
<!DOCTYPE html>
<html>
<head>
<title>Input Week autofocus</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Week-autofocus</legend>
<label for="WeekSelect">Target Week :
<input type="week" id="WeekSelect" value="2019-W24" autofocus>
</label>
<input type="button" onclick="removeAutofocus()" value="Remove Autofocus">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputWeek = document.getElementById("WeekSelect");
divDisplay.textContent = 'Autofocus: '+inputWeek.autofocus;
function removeAutofocus() {
inputWeek.autofocus = false;
divDisplay.textContent = 'Autofocus: '+inputWeek.autofocus;
}
</script>
</body>
</html>
Output
This will produce the following output −
Before clicking ’Remove Autofocus’ button −

After clicking ‘Remove Autofocus’ button −

Advertisements