Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 淡入div不';它不会褪色,但已经存在了_Jquery_Function_Fadein_Fade_Fadeout - Fatal编程技术网

Jquery 淡入div不';它不会褪色,但已经存在了

Jquery 淡入div不';它不会褪色,但已经存在了,jquery,function,fadein,fade,fadeout,Jquery,Function,Fadein,Fade,Fadeout,我制作了这个简单的jQuery脚本,但我有一个小问题。 在我淡出我的第一个div后,我的第二个fadeIn不起作用,因为div已经在那里了。。。我已经试着用更多的毫秒来减慢fadeIn的速度,但是没有成功。这是我的剧本 $("#nothing > h1").click(function(){ $(this).fadeOut(1000); $("#social").fadeIn(1000); }); 这是我的HTML <div id="nothing"> <

我制作了这个简单的jQuery脚本,但我有一个小问题。 在我淡出我的第一个div后,我的第二个fadeIn不起作用,因为div已经在那里了。。。我已经试着用更多的毫秒来减慢fadeIn的速度,但是没有成功。这是我的剧本

$("#nothing > h1").click(function(){
$(this).fadeOut(1000);
$("#social").fadeIn(1000);  
  });
这是我的HTML

<div id="nothing">
    <h1>Click here.</h1>
</div>

<div id="social">      
   <h2>Nothing to see here</h2>
</div>


点击这里。
这里没什么可看的


谢谢

如果这是按顺序发生的,则必须在
fadeOut
事件的回调中调用
fadeIn()
,如下所示:

$("#nothing > h1").click(function(){
   $(this).fadeOut(1000, function() {
     $("#social").fadeIn(1000);
   });    
});

希望这有帮助

这是我为您制作的JSFIDLE:


请提供html标记
$('#social').hide();

 $("#nothing > h1").click(function(e){
     e.preventDefault();// Just in case

     //You probally would want to fade out the parent of the h1 so add parent() 
     $(this).parent().fadeOut(1000, function() { 
         $("#social").fadeIn(1000);
     });

});