Home > Web Front-end > H5 Tutorial > body text

Introduction to the autofocus attribute in HTML5_html5 tutorial skills

WBOY
Release: 2016-05-16 15:48:04
Original
2316 people have browsed it

A simple HTML5 function to be discussed here is to allow the input focus to automatically fall on an element when the page is loaded; this action is completed using the autofocus attribute.

HTML code is very simple:

Copy the code
The code is as follows:

< ;!-- These all work! -->


< ;textarea autofocus="autofocus">

With the autofocus attribute, these INPUT, TEXTAREA, or BUTTON elements can be selected when the page loads. But if you use pure display elements, such as H1 tags, the autofocus attribute is not easy to use.

This property can be very useful in certain situations. For example, Google's homepage is where people use it to search 99% of the time, so once the page is loaded, the cursor must be positioned in the input box. In the past, JavaScript was needed to complete it, but now it is no longer necessary, HTML can complete it by itself.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template