<html>
<body>
<p id="demo">Click the button to see if the body element has any attributes</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var x=document.getElementById("demo");
x.innerHTML=document.body.hasAttributes();
}
</script>
<p>Try adding an attribute to the body element, and the result will be <em>true</em> instead of <em>false</em>.</p>
<p><strong>Note:</strong> Internet Explorer 8 and earlier does not support the hasAttributes method.</p>
</body>
</html>