English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The autofocus attribute is a boolean attribute. If present, it specifies that the button should automatically receive focus when the page loads.
Button using autofocus attribute:
<!DOCTYPE html> <html> <head> <title>HTML:<button> autofocus attribute - 基础教程网 oldtoolbag.com</title> <body> <button type="button" autofocus onclick="alert('Hello world!39;) Click Me!/button> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
Internet Explorer 10, Firefox, Chrome, and Safari support the autofocus attribute.
Note: Internet Explorer 9 and earlier IE versions do not support the autofocus attribute.
The autofocus attribute is a boolean (boolean) attribute.
The autofocus attribute specifies that the button should automatically gain focus when the page is loaded.
The autofocus attribute is a difference between HTML5new attributes in the <button> tag.
In XHTML, attribute abbreviations are not allowed, the autofocus attribute must be defined as <button autofocus="autofocus">.
<button type="button" autofocus>