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 |
瀏覽器相容性
載入中…