Node.hasAttributes

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

hasAttributes属性返回一个布尔值truefalse,来表明当前元素节点是否有至少一个的属性 (attribute).

语法

js
hasAttributes()

示例

js
var t1 = document.getElementById("table-data");

if (t1.hasAttributes()) {
  // 可以用 t1.attributes 来读取该元素的所有属性
}

规范