autofocus

HTML Autofocus Attribute (HTML自动对焦属性)

The HTML autofocus attribute is a boolean attribute, which defines that an <input> element must automatically get focus when the page loads.

The autofocus attribute is new in HTML5. (自动对焦属性是HTML5中的新属性。)

Syntax

Syntax (语法)

<input autofocus>
类目类目
Applies toHTML <input> element.

Example of the HTML autofocus attribute:

<!DOCTYPE html>
<html>
 <head>
   <title>Title of the document.</title>
 <body>
   <h1>Example of the HTML "autofocus" attribute.</h1>
   <form action="#">
     Name: <input type="text" name="fname" autofocus><br>
     Surname: <input type="text" name="lname"><br>
     <input type="submit">
   </form>
 </body>
</html>


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部