HTML:標記語言
CSS:樣式語言
JavaScript:指令碼語言
Web API:程式設計介面
所有 Web 技術
學習 Web 開發
發現我們的工具
更好地瞭解 MDN
此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 2015 年 7 月以來,各瀏覽器均已提供此特性。
Element 介面的 hasAttributes() 方法返回一個布林值,指示當前元素是否具有任何屬性。
Element
hasAttributes()
無。
布林值。
let foo = document.getElementById("foo"); if (foo.hasAttributes()) { // Do something with 'foo.attributes' }
載入中…
Element.attributes
Element.hasAttribute()
Element.getAttribute()
Element.setAttribute()
Element.removeAttribute()
Element.toggleAttribute()