天天看点

Input Number autofocus 属性

Input Number autofocus 属性

Input Number 对象

查看 number 字段是否在页面加载后自动获取焦点:

var x = document.getElementById("myNumber").autofocus;

x 输出结果为:

true

autofocus 属性用于设置或者返回 number 字段在页面加载后是否自动获取焦点。

该属性反映了 HTML autofocus 属性。

Input Number autofocus 属性
Input Number autofocus 属性
Input Number autofocus 属性
Input Number autofocus 属性
Input Number autofocus 属性

所有主流浏览器都支持 autofocus 属性。

注意: Internet Explorer 9 及更早IE版本、 Opera 12 及更早Opera版本浏览器不支持该属性。

注意: Internet Explorer 9及更早IE版本不支持使用 type="number" 属性的 <input> 元素。

返回 autofocus 属性:

numberObject.autofocus

设置 autofocus 属性:

numberObject.autofocus=true|false

描述

true|false

描述了 number 字段在页面加载后是否获取焦点

true - number 字段获取焦点

false - 默认。number 字段不获取焦点

返回值:

布尔值,如果页面在加载后 number 字段自动获取焦点返回 true,否则返回false。

HTML 参考手册: HTML <input> autofocus 属性

Input Number autofocus 属性