x
 
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM 属性</h1>
<h2>length 属性</h2>
<p>点击“试一试”可显示按钮的属性数:</p>
<button id="myButton" onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
  let numb = document.getElementById("myButton").attributes.length;
  document.getElementById("demo").innerHTML = numb;
}
</script>
</body>
</html>