I need was when a popup comes and user clicks any where in the document except the popup, the popup should fadeout.
I have tried out with target.attr method, but failed in Mozilla.
IS there any Idea ? Thanks in Advance
I need was when a popup comes and user clicks any where in the document except the popup, the popup should fadeout.
I have tried out with target.attr method, but failed in Mozilla.
IS there any Idea ? Thanks in Advance
You can use the jQuery fadeout method and one method.
Something like :
jQuery("#yourpoup").click(function(){ return false; });
jQuery(document).one("click", function() { jQuery("#yourpoup").fadeOut(); });
According to this question, using this is better then using bind.
There is also a JQuery plugin for click outside, this will allow you to handle the click even for everything BUT the pop up.
http://benalman.com/projects/jquery-outside-events-plugin/
$("#yourpopup").bind( "clickoutside", function(event){
$(this).fadeOut(500);
});
If your pop-up is a JQuery Dialog, you can see this thread:
Use jquery as example, assumed $popup
is the your popup element
$('body').click(function(){
// hide the popup here
});
$popup.click(function(e) {
// do something here if needed
e.stopPropagation();
});
The key is when click in the popup, stop bubble the event to body, so will not fire the function attached to body.