Multiple popup links with them affecting each other
I have created 2 popup dialog box when you click on a link.
What I am trying to do:
If I open one popup and try to open another popup the opened popup box would disappear Plus when I open them both and click on the close button they both close also the same as cli开发者_Python百科ck on the link again - how can i separate this??
Here is the example: http://jsfiddle.net/zidski/ZBfTy/
If you want them mutual exclusive, you could just run close_modal();
before you open a box.
http://jsfiddle.net/Znarkus/ZBfTy/4/
If you have two of them open to close one of them you would need to change your code like so:
$('.close_modal').click(function(){
//use the function to close it
close_modal(this); // Passing the clicked link to the function
});
});
//THE FUNCTIONS
function close_modal(link){
//hide the mask
$('#mask').fadeOut(500);
//hide modal window(s)
// using the clicked link to get the parent to close.
$(link).parent().fadeOut(500);
}
you got problem in close function. here is changed one.
close_modal(this);
function close_modal(t){
//hide the mask
$("#mask").fadeOut(500);
//hide modal window(s)
$(t).parent().parent().children('.modal_window').fadeOut(500);
}
精彩评论