DOM
Element 接口的 hasAttributes() 方法返回一个表示当前元素是否具有任何属性的布尔值。
语法
hasAttributes()
参数
无。
返回值
布尔值。
示例
let foo = document.getElementById("foo");
if (foo.hasAttributes()) {
// 对“foo.attributes”进行操作
}
规范
浏览器兼容性
参见
- Element.attributes
- Element.hasAttribute()
- Element.getAttribute()
- Element.setAttribute()
- Element.removeAttribute()
- Element.toggleAttribute()
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
