折雨的天空
jquery版本升级带来的烦恼-toggle
2015-7-8 我好笨


实际上toggle还是很好用







但是在1.9以后的版本里被淘汰了。







于是总要有替代办法吧,搜一下就可以了







以下代码是复制别人的







$('#show').click(function(e){
 
    if($('.pop').is(':visible')) {
       $('.pop').hide();
     }
     else {
       $('.pop').show();
     }
     e.stopPropagation();
});
 
 
$(document).click(function (e)
{
    var container = $(".pop");
 
    if (!container.is(e.target) // if the target of the click isn't the container...
        && container.has(e.target).length === 0) // ... nor a descendant of the container
    {
        container.hide();
    }
});



发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容