x
 
<!DOCTYPE html>
<html>
<body>
<p id="demo">请点击按钮来查明按钮是否指定了 onclick 属性。</p>
<button onclick="myFunction()">试一下</button>
<script>
function myFunction()
{
var btn=document.getElementsByTagName("BUTTON")[0];
var x=document.getElementById("demo");
x.innerHTML=btn.getAttributeNode("onclick").specified;
}
</script>
</body>
</html>