HTMLInputElement: accept 属性
accept 属性是 HTMLInputElement 接口的一部分,它反映了 <input> 元素的 accept 属性。该属性通常是一个逗号分隔的文件类型标识符列表,用于提示 <input type="file"> 元素期望的文件类型。如果未显式设置该属性,则 accept 属性为空字符串。
值
一个字符串,表示元素的 accept 值,如果未显式设置 accept,则为空字符串。
示例
js
const inputElement = document.querySelector("#time");
console.log(inputElement.accept); // the current value of the accept attribute
inputElement.accept = ".doc,.docx,.xml,application/msword"; // sets the accept value
规范
| 规范 |
|---|
| HTML # dom-input-accept |
浏览器兼容性
加载中…