[Event Target] Can't identify clicked element id
I'm pretty new to this forum, so Hello Everyone ;)
I have written this proto to fadeout/close my "hint/tooltip" div, when i ckick anywhere in the page.
- Element.prototype.hintClickOut = function(hint_id) {
- var el=this;
- $('*').click( function(event) {
- var e = window.event || event;
- var targ = e.target || e.srcElement;
- if(targ.id == el.id) return;
-
- $('#'+hint_id).fadeOut(500, function() { $(this).remove(); });
-
- });
- }
and i call it on a HTML Select, by onChange event listener.
It works fine in Chrome, but NOT in Firefox.
The problem is, when i perform this check
- if (targ.id == el.id) return;
to avoid closing my element after clicking it's select (el.id refers to the select id)
Firefox doesn't "return", and so it goes on and reaches the "fadeout/close" line.
Maybe there's a way to check ALL the objects inside "event target" and,
IF if find one element which has "id == el.id", THEN return;
Hope
I have made that clear.
TY ;)