I have an html page containing a list of items with an image against each item.
<ul>
<li>
<div>
<div class="text"> Text 1</div>
<img src="../../Images/Notes.png" class="smallSizeLogo notes"
</div>
<div>
<div class="text"> Text 2</div>
<img src="../../Images/Notes.png" class="smallSizeLogo notes"
</div>
</li>
<\ul>
I want to raise an event if clicked anywhere in the html except the image. Is there a way to do it in jquery?
答案 0 :(得分:6)
Use event.target
$(document).click(function(event){
if(event.target.tagName != 'IMG'){
//code here
}
});