<html>
<body>
<p>单击按钮可查看 body 元素是否具有任何属性。</p>
<button onclick="myFunction()">试一试</button>
<p>尝试向 body 元素添加一个属性,结果将是 <em>true</em> 而不是 <em>false</em>。</p>
<p><strong>注意:</strong>Internet Explorer 8 及更早版本不支持 hasAttributes() 方法。</p>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.body.hasAttributes();
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>