已废弃 Gecko 22 (Firefox 22 / Thunderbird 22 / SeaMonkey 2.19)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
概述
hasAttributes
属性返回一个布尔值true
或false
,来表明当前元素节点是否有至少一个的属性(attribute).
语法
result = targetNode.hasAttributes();
示例
var t1 = document.getElementById("table-data"); if ( t1.hasAttributes() ) { // 可以用t1.attributes来读取该元素的所有属性 }