Introduction to the use of HTML5 autofocus attribute_html5 tutorial skills
WBOYOriginal
2016-05-16 15:49:102866browse
Original text: HTML5 autofocus Attribut Original publication time: August 27, 2012 Translation time: August 6, 2013 HTML5 has launched a lot of wonderful features Something for us. In the past we had to use JavaScript and Flash to complete tasks, such as form validation, input box blank prompts (INPUT placeholders), client side file upload and download (client side file naming) , as well as audio/video playback, can now be accomplished with basic HTML. Another simple HTML feature now allows us to automatically set input focus to the desired element after the page has finished loading, via an attribute called autofocus. The code is as simple as:
Copy the code
The code is as follows:
When the autofocus attribute is set, the input, textarea, and button elements will be automatically selected after the page is loaded. (That is, getting focus). I tried other elements (such as h1 tags), tabIndex=0, but the autofocus attribute has no effect at all on these elements. This attribute is useful on pages whose main purpose is collecting information, such as the Google homepage (99% of the time it is used for search) or online installation wizards (such as WordPress's installer) .And the most important thing is - no JavaScript is required. The complete page code is as follows:
Copy the code
The code is as follows:
HTML5 autofocus attribute test
body>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn