x
 
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Attributes</h1>
<h2>getNamedItem() 方法</h2>
<button id ="myButton" onclick="myFunction()">按钮</button>
<p>按钮的 onclick 属性的值是:</p>
<p id="demo"></p>
<script>
const nodeMap = document.getElementById("myButton").attributes;
let value = nodeMap.getNamedItem("onclick").value;  
document.getElementById("demo").innerHTML = value;
function myFunction() {}
</script>
</body>
</html>