I am having a html structure as
<div class="abc">
<div id="test">
<label>Name</label>
<input type="checkbox">
<label>Name</label>
<input type="checkbox">
<label>Name</label>
<input type="checkbox">
</div>
</div>
I want that when i click outside of div id test, a particular function can be called. and also no event shall be triggered when inside the div id test i.e when I click the checkboxes, no event shall be triggered.
Any help will be really appreciated.
You can achieve it by the following code (demo : http://jsfiddle.net/CrfCD/)
$(document).ready(function(){
$(document).click(function(e){
if ($(e.target).is('#test,#test *')) {
return;
}
else
{
alert("Hi");
//Perform your event operations
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With