Javascript - proper getAttributeNode on IE6+
Posted
by
Darrow
on Stack Overflow
See other posts from Stack Overflow
or by Darrow
Published on 2011-01-13T01:21:21Z
Indexed on
2011/01/13
1:53 UTC
Read the original article
Hit count: 214
JavaScript
|attributes
I have a regular input box (no onchange attribute).
<input type="text" id="bar" name="bar" />
For some reason, IE6+ does returns [object], while FF and Chrome returns null.
if ((elem.getAttributeNode('onchange')) != null)
elem.onchange();
I did also try as:
if (typeof(elem.onchange) !== 'undefined')
elem.onchange();
What would be the proper cross-browser way to check if the element has the attribute?
Thanks
© Stack Overflow or respective owner