Jquery <;p>;淡出后无法显示,什么';怎么了?
为什么#hello可以淡出但不再显示??谢谢Jquery <;p>;淡出后无法显示,什么';怎么了?,jquery,Jquery,为什么#hello可以淡出但不再显示??谢谢 <!DOCTYPE html> <html> <head> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <meta charset=utf-8 /> <title>JS Bin</title> <!-
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
</style>
<script>
$(function() {
$('#hello').delay(1000).fadeOut();
$('#hello').show();
});
</script>
</head>
<body>
<p id="hello">Hello World</p>
</body>
</html>
JS-Bin
文章、旁白、数字、页脚、页眉、H组、,
菜单,导航,部分{显示:块;}
$(函数(){
$('#hello').delay(1000.fadeOut();
$(“#您好”).show();
});
hello World
您必须通过向淡出效果提供回调来等待淡出效果完成:
$(function() {
$('#hello').delay(1000).fadeOut('slow', function() {
$('#hello').show();
});
});
在启动.fadeOut()
之前,将调用.show()
试试这个:
$('#hello').delay(1000).fadeOut(function(){
$('#hello').show();
});
示例:在您的示例中,
show()
函数在fadeOut
完成之前被调用。如果将其更改为:
$('hello').delay(1000).fadeOut(函数(){$('hello').show()})代码>
然后,淡出完成后,hello
p
元素将再次出现。它可以,问题是由于您的延迟,.show()
在.fadeOut()
之前被调用
要修复此问题,请尝试:
$('#hello').delay(1000).fadeOut().show(); //Will reappear immediately
或
使用淡出回调指定动画结束时要执行的操作
$(function() {
$('#hello').delay(1000).fadeOut(function() {
$('#hello').show();
});
});
什么?你的问题没有道理。
$(function() {
$('#hello').delay(1000).fadeOut(function() {
$('#hello').show();
});
});