开发者

This JQuery works in Chrome and Safari, Not FF?

开发者 https://www.devze.com 2023-03-20 01:57 出处:网络
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 o

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(){...});
0

精彩评论

暂无评论...
验证码 换一张
取 消