Jquery 淡入div不';它不会褪色,但已经存在了
我制作了这个简单的jQuery脚本,但我有一个小问题。 在我淡出我的第一个div后,我的第二个fadeIn不起作用,因为div已经在那里了。。。我已经试着用更多的毫秒来减慢fadeIn的速度,但是没有成功。这是我的剧本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"> <
$("#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);
});
});