This JQuery works in Chrome and Safari, Not FF?
I have a bunch of code that will open and close a div using the slidetoggle/toggleclass method
Now while the DIv is opened, I added in this little bit to allow the window to close if someone clicks outside of the now opened div.
$("body").live("click", function() {
if($(event.target).parents().index($('.subpanel')) == -1)
{
if($('.subpanel').is(":visible"))
{
$(".alerts").toggleClass("notiftitleactive");
$(".alerts").toggleClass("active").next().slideToggle(50);
$("body").die("click");
}
}
});
This works perfectly well in google chome and safari. But in firefox, clicking outside of the div does nothing (does not trigger the .alerts to toggleclass/slidetoggle).
Any idea why thi开发者_如何学JAVAs wouldnt work in FF ?
Thanks!
Try using either
$(document).click(function(){...});
or
$(window).click(function(){...});
精彩评论