HTML DOM Input Month 对象

2023-04-10 11:15 更新

Input Month 对象是 HTML5 新增的。

Input Month 对象表示使用type="month" 的 HTML <input> 元素。

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

访问 Input Month 对象

你可以使用 getElementById() 函数来访问使用 type="month" 属性的 <input> 元素:

var x = document.getElementById("myMonth");尝试一下

提示: 你同样可以通过表单的元素集合来访问 Input Month 对象。

创建 Input Month 对象

你可以使用 document.createElement() 方法来创建使用 type="month" 属性的 <input> 元素:

var x = document.createElement("INPUT");
x.setAttribute("type", "month");尝试一下

Input Month 对象属性

属性 描述
autocomplete 设置或返回 month 字段的 autocomplete 属性值
autofocus 设置或返回 month 字段在页面加载后是否自动获取焦点
defaultValue 设置或返回 month 字段默认的值
disabled 设置或返回 month 字段是否可用
form 返回使用 month 字段的表单引用
list 返回包含了 month 字段的 datalist 引用
max 设置或返回 month 字段的 max 属性值
min 设置或返回 month 字段的 min 属性值
name 设置或返回 month 字段的 name 属性值
readOnly 设置或返回 month 字段是否只读
required 设置或返回 month 字段在表单中是否为必填字段
step 设置或返回 month 字段的 step 属性值
type 返回 month 字段的表单元素类型
value 设置或返回 month 字段的 value 属性值

标准属性和事件

Input Month 对象同样支持标准 属性事件


相关文章

HTML 教程: HTML 表单

HTML 参考手册: HTML <input> 标签

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

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号