Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>Click the button to display the value of the onclick attribute node of the button element.</p>

<button id="myBtn" onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var elmnt = document.getElementById("myBtn");
    var attr = elmnt.getAttributeNode("onclick").value;
    document.getElementById("demo").innerHTML = attr;
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy