I have a click function defined on the document and when clicked I want to know if the target contains a class ‘dropdown’ the function should return. So this is what works fine in Firefox:
$(document).click(function(e){
if (e.target.classList.contains('dropdown'))
return;
//Other work here;
});
But somehow IE shows e.target as null. After reading some where that IE does not have target for click events but srcElement, and to work in both browsers I need to change this to:
(event.target || event.srcElement).id //etc
But I need to get the class attribute, does some one know how to get the class of the srcElement in IE “WITHOUT USING JQUERY”?
Why not use the JQuery API function hasClass?
You should be able to replace
with
~~~~~~~~~~~~Edit~~~~~~~~~~
For that matter, if I understand what you’re doing, perhaps you should restructure your whole event handler (unless you’re doing it for efficiency reasons sometimes people catch a larger exception then figure out what was clicked)