<a id="a" onclick='alert("hi");'>hi</a>
click, get "hi". Open a shell and go:
a = document.getElementById("a")
a.setAttribute("onclick", function(){return false;})
Click. Nothing.
a = document.getElementById("a")
a.removeAttribute("onclick")
what's the difference between getAttribute and getAttributeNode
If I RTFD (http://developer.mozilla.org/en/docs/DOM:element) properly,
getAttribute returns the *value* of the attribute and getAttributeNode
returns an Attr node...
HTML:
<a id="a" onclick='alert("hi");'>hi</a>
Script:
a = document.getElementById("a");
a.getAttribute("onclick");
--> alert("hi")
a.getAttributeNode("onclick");
--> Attr:
localName = onclick
nodeValue = alert("hi")
nodeName = onclick
Try it in FireBug!
Dave
Thanks