开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜