Latest web development tutorials

HTML DOM Input Month autofocus 屬性

Input Month 對象參考手冊 Input Month對象

實例

查看month 字段是否在頁面加載後自動獲取焦點:

var x = document.getElementById("myMonth").autofocus;
x輸出結果為:
true

嘗試一下»

定義和用法

autofocus 屬性用於設置或者返回month 字段在頁面加載後是否自動獲取焦點。

該屬性反映了HTML autofocus 屬性。


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流瀏覽器都支持autofocus 屬性。

注意: Internet Explorer 9及更早IE版本、 Opera 12及更早Opera版本瀏覽器不支持該屬性。

注意: Internet Explorer或Firefox瀏覽器不支持使用type="month"屬性的<input>元素。


語法

返回autofocus 屬性:

monthObject .autofocus

設置autofocus 屬性:

monthObject .autofocus=true|false

屬性值

描述
true|false 描述了 month 字段在页面加载后是否获取焦点
  • true - month 字段获取焦点
  • false - 默认。month 字段不获取焦点。

技術細節

返回值: 布爾值,如果頁面在加載後month 字段自動獲取焦點返回true,否則返回false。


相關頁面

HTML參考手冊: HTML <input> autofocus屬性


Input Month 對象參考手冊 Input Month對象