Javascript - proper getAttributeNode on IE6+
- by Darrow
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