Javascript examples for DOM:Attribute
The specified property returns true if the attribute is specified or created not attached yet.
Otherwise it returns false.
A Boolean, returns true if the attribute is specified, otherwise false
The following code shows how to Find out if an attribute has been specified or not:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from ww w . java 2 s . c o m*/ var btn = document.getElementsByTagName("BUTTON")[0]; var x = btn.getAttributeNode("onclick").specified; document.getElementById("demo").innerHTML = x; } </script> </body> </html>