892 B
892 B
title | localeTitle |
---|---|
Autofocus Attribute | 自动对焦属性 |
自动对焦属性| HTML5
autofocus属性是布尔属性。
如果存在,它指定元素应在页面加载时自动获得输入焦点。
文档中只有一个表单元素可以具有自动聚焦属性。它不能应用于<input type="hidden">
。
适用于
|元素|属性| | : - | : - | | <button>
|自动对焦| | <input>
|自动对焦| | <select>
|自动对焦| | <textarea>
|自动对焦|
例
<form>
<input type="text" name="fname" autofocus>
<input type="text" name="lname">
</form>
兼容性
这是一个HTML5属性。
更多信息:
w3schools.com上的HTML自动对焦属性
MDN Web文档上的 autofocus属性