How can I do that?
event.target
returns a HTML object,
and my element is a jQuery object.
Is there a better way to find out if event.tar
You can get the actual DOM element from the jQuery using .get(0)
or simply the_element[0]
. It would probably be better to check with jQuery, though.
if (the_element.is(event.target))
{
...
}
Using your example:
$(document).click(function(event){
if (the_element.is(event.target)) {
return false;
}
if(($(event.target).parents().index(box) == -1)
&& box.is(':visible')){
close();
}
});