Javascript examples for DOM:Element getAttributeNode
Element getAttributeNode() Method - Get the value of the onclick attribute node of a <button> element:
<!DOCTYPE html> <html> <body> <button id="myBtn" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w . java2s . c om var elmnt = document.getElementById("myBtn"); var attr = elmnt.getAttributeNode("onclick").value; document.getElementById("demo").innerHTML = attr; } </script> </body> </html>