<!DOCTYPE html>
<html>
<body>
<p>Click the button find out if the button has an onclick attribute specified.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var btn = document.getElementsByTagName("BUTTON")[0];
var x = btn.getAttributeNode("onclick").specified;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>