I have a div element, with img element in it.
onclick of div i make one function, and onclick on img – another. but when i click on img it make the first function too, because the img is in div element.
so, i think, that if there were something like isClicked, onclick of div i can just verify, if img is Not clicked …
(i can write a logic, and verify it by so,for example onclick of img i can add a class to somebody… but maybe there is a function for it?)
Thanks
Update:
<div class="left_expended" style="position: relative;">
Լեզուներ
<img src="images/new_page.gif" id="new_lang" title="Լեզու ավելացնել" />
</div>
and jquery
$(".left_expended").live('click', function(){
$(this).addClass("left_collapsed");
$(this).removeClass("left_expended");
$(this).next("div .container").slideUp(400);
});
$("#new_lang").click(function()
{
alert("something");
});
onclick of img it makes first function too.
You can prevent the click on the
<img>from going up to the<div>usingevent.stopPrpagation(), like this:What happens normally is that events bubble, the
clickon the<img>“bubbles up” to the<div>afterwards…unless you stop it, which is exactly what.stopPropagation()does. This way anything activating your$("div").click(...)is anywhere inside except the image, because a click there wouldn’t go up anymore, which seems to be what you’re after 🙂