
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input Submit autofocus property
The HTML DOM Input Submit autofocus property is associated with the HTML <input> element’s autofocus attribute. This property is used for setting or returning if the submit button should be automatically focused when the page loads or not.
Syntax
Following is the syntax for −
Setting the autofocus property −
submitObject.autofocus = true|false
Here, true represents that the submit button should get focus and false represents otherwise. It is set to false by default.
Example
Let us look at an example for the Input Submit autofocus property −
<!DOCTYPE html> <html> <body> <h1> Submit Autofocus property</h1> <form action=”/Sample_page.php” style="border:solid 2px green;padding:2px"> UserName: <input type="text" id="USR"><br> Location: <input type="text" id=“Loc”><br><br> <input type="submit" id="SUBMIT1" autofocus> </form> <p>Get the submit button autofocus property value by clicking the below button</p> <button type="button()" onclick="FocusVal()">CHECK</button> <p id="Sample"></p> <script> function FocusVal(){ var f = document.getElementById("SUBMIT1").autofocus; document.getElementById("Sample").innerHTML = "The submit button autofocus property is set to: "+f; } </script> </body> </html>
Output
This will produce the following output −
On clicking the CHECK button −
- Related Articles
- HTML DOM Input URL autofocus Property
- HTML DOM Input Week autofocus Property
- HTML DOM Input Password autofocus Property
- HTML DOM Input Search autofocus Property
- HTML DOM Input Text autofocus Property
- HTML DOM Input Radio autofocus property
- HTML DOM Input Range autofocus property
- HTML DOM Input Reset autofocus property
- HTML DOM Input Checkbox autofocus Property
- HTML DOM Input Month autofocus Property
- HTML DOM Input Number autofocus Property
- HTML DOM Input Color autofocus Property
- HTML DOM Input Date autofocus Property
- HTML DOM Input Datetime autofocus Property
- HTML DOM Input Email autofocus Property

Advertisements