代码示例:(标识:jsck_node_hasattributes)
<!DOCTYPE html>
<html>
<body>

<h1>Element 对象</h1>

<h2>hasAttributes() 方法</h2>

<p>body 元素的属性有:</p>

<p id="demo"></p>

<p>向 body 元素添加一个属性,结果将为 true。</p>

<script>
let answer = document.body.hasAttributes();
document.getElementById("demo").innerHTML = answer;
</script>

</body>
</html>
运行结果: