实际上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();
    }
});