Javascript 使用jQuery创建自定义切换

Javascript 使用jQuery创建自定义切换,javascript,jquery,toggle,Javascript,Jquery,Toggle,我有下面的代码,它在HTML中通过.load淡入.pop-up模式 $('.about').click(function(){ $('.pop-up').load('about.php', function(){ $(this).fadeIn(); }); 但是,我需要再次单击以使.about淡出。我知道某些切换函数现在已被弃用。目前有没有一种方法我可以使用?我有几个这样的函数,需要在整个代码中切换 任何帮助都会很好 $('.about').click(func

我有下面的代码,它在HTML中通过
.load
淡入
.pop-up
模式

$('.about').click(function(){
    $('.pop-up').load('about.php', function(){
        $(this).fadeIn();
    });
但是,我需要再次单击以使
.about
淡出。我知道某些切换函数现在已被弃用。目前有没有一种方法我可以使用?我有几个这样的函数,需要在整个代码中切换

任何帮助都会很好

$('.about').click(function(){
  $('.pop-up').load('about.php', function(){
    $(this).toggle( "slow", function() {
    // Animation complete.
  });
});

您可以使用但通过自定义代码,您可以很好地进行自定义

    var toggle=0;
    $('.about').click(function(){
   var $this=$('this');
    if(!toggle)
    {
    $('.pop-up').load('about.php', function(){
            $this.fadeIn();
          toogle=1;
        });
    }
    else{// or do other action which you want
           $this.fadeOut();
        toggle=0;

    }
    });

你能创建一个提琴吗?类似这样的东西请参见toggle方法未被弃用,toggle事件为否。可以使用。