I am trying to make a simple plugin, so when the user clicks on the photo, he gets a bigger photo (because all photos are smaller that the real ones). And my question is, how can this bigger photo close when the user clicks on body or html, but it shouldn’t close it if it was clicked on the photo? It probably should look like this:
$('body, html').click(function() {
if(clickedOnPhoto)
//do nothing
else
//close the photo
})
Rather than checking what the target was and deciding what to do; you can add a
clickevent handler to thedocumentelement to close big photos and add aclickevent handler to the big photos that stops the propagation of theclickevent so it doesn’t reach thedocumentelement: