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
It seems to me that you wish to know if onchange is a function or not, in which case you can just do
if(typeof elem.onchange == 'function')
精彩评论