admin管理员组文章数量:1026941
I'm trying to fade out a div, then fade in another div, and that works for me, the problem is I'm not able to delay it, so first div doesn't push the other div down...
This is my HTML (everything is inline):
<!doctype html>
<html>
<head>
<title>JavaScript popup</title>
<meta charset="utf-8">
<script src=".12.0/jquery.min.js"></script>
<script src="main.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
$(".main").hide();
});
$("#continue-button").click(function(){
$(".vge-eksponering").hide();
$(".main").show();
});
</script>
<body style="background-color:lightgrey;">
<div class="vge-eksponering" style="text-align:center;">
<h1>Tjek VGEs hjemmeside ud på:
<br>
<a href="" target="_blank">www.vge.dk</a></h1>
<button id="continue-button" style="font-size:2em;">Fortsæt til VGE News</button>
</div>
<script>
$("#continue-button").click(function(){
$(".vge-eksponering").fadeOut(1200);
$(".main").fadeIn(1200);
});
</script>
<div class="main" style="background-color:lightblue;">
<h1>JavaScript popup</h1>
<p>Hopefully this will work soon...</p>
</div>
</body>
</html>
I'm trying to fade out a div, then fade in another div, and that works for me, the problem is I'm not able to delay it, so first div doesn't push the other div down...
This is my HTML (everything is inline):
<!doctype html>
<html>
<head>
<title>JavaScript popup</title>
<meta charset="utf-8">
<script src="https://ajax.googleapis./ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="main.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
$(".main").hide();
});
$("#continue-button").click(function(){
$(".vge-eksponering").hide();
$(".main").show();
});
</script>
<body style="background-color:lightgrey;">
<div class="vge-eksponering" style="text-align:center;">
<h1>Tjek VGEs hjemmeside ud på:
<br>
<a href="http://www.vge.dk" target="_blank">www.vge.dk</a></h1>
<button id="continue-button" style="font-size:2em;">Fortsæt til VGE News</button>
</div>
<script>
$("#continue-button").click(function(){
$(".vge-eksponering").fadeOut(1200);
$(".main").fadeIn(1200);
});
</script>
<div class="main" style="background-color:lightblue;">
<h1>JavaScript popup</h1>
<p>Hopefully this will work soon...</p>
</div>
</body>
</html>
EDIT: I used this, and it worked.
$(".vge-eksponering").fadeOut(1200);
$(".main").delay(1200).fadeIn(1200);
Share
Improve this question
edited Feb 4, 2016 at 20:24
Kevin From
asked Feb 4, 2016 at 18:16
Kevin FromKevin From
1522 silver badges10 bronze badges
1
-
You want to fade out
.vge-eksponering
and, when it's done fading out, fade in.main
? – T.J. Crowder Commented Feb 4, 2016 at 18:19
2 Answers
Reset to default 6You have (at least) two choices:
If there's only one .vge-eksponering
element, then use the pletion callback fadeOut
gives you:
$(".vge-eksponering").fadeOut(1200, function() {
$(".main").fadeIn(1200);
});
Or just use delay
with a value equivalent to the first fadeOut:
$(".vge-eksponering").fadeOut(1200);
$(".main").delay(1200).fadeIn(1200);
use setInterval
setInterval(function() {
$(".main").fadeIn(1200);
}, 1200);
a tutorial on setInterval
http://www.w3schools./jsref/met_win_setinterval.asp
I'm trying to fade out a div, then fade in another div, and that works for me, the problem is I'm not able to delay it, so first div doesn't push the other div down...
This is my HTML (everything is inline):
<!doctype html>
<html>
<head>
<title>JavaScript popup</title>
<meta charset="utf-8">
<script src=".12.0/jquery.min.js"></script>
<script src="main.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
$(".main").hide();
});
$("#continue-button").click(function(){
$(".vge-eksponering").hide();
$(".main").show();
});
</script>
<body style="background-color:lightgrey;">
<div class="vge-eksponering" style="text-align:center;">
<h1>Tjek VGEs hjemmeside ud på:
<br>
<a href="" target="_blank">www.vge.dk</a></h1>
<button id="continue-button" style="font-size:2em;">Fortsæt til VGE News</button>
</div>
<script>
$("#continue-button").click(function(){
$(".vge-eksponering").fadeOut(1200);
$(".main").fadeIn(1200);
});
</script>
<div class="main" style="background-color:lightblue;">
<h1>JavaScript popup</h1>
<p>Hopefully this will work soon...</p>
</div>
</body>
</html>
I'm trying to fade out a div, then fade in another div, and that works for me, the problem is I'm not able to delay it, so first div doesn't push the other div down...
This is my HTML (everything is inline):
<!doctype html>
<html>
<head>
<title>JavaScript popup</title>
<meta charset="utf-8">
<script src="https://ajax.googleapis./ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="main.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
$(".main").hide();
});
$("#continue-button").click(function(){
$(".vge-eksponering").hide();
$(".main").show();
});
</script>
<body style="background-color:lightgrey;">
<div class="vge-eksponering" style="text-align:center;">
<h1>Tjek VGEs hjemmeside ud på:
<br>
<a href="http://www.vge.dk" target="_blank">www.vge.dk</a></h1>
<button id="continue-button" style="font-size:2em;">Fortsæt til VGE News</button>
</div>
<script>
$("#continue-button").click(function(){
$(".vge-eksponering").fadeOut(1200);
$(".main").fadeIn(1200);
});
</script>
<div class="main" style="background-color:lightblue;">
<h1>JavaScript popup</h1>
<p>Hopefully this will work soon...</p>
</div>
</body>
</html>
EDIT: I used this, and it worked.
$(".vge-eksponering").fadeOut(1200);
$(".main").delay(1200).fadeIn(1200);
Share
Improve this question
edited Feb 4, 2016 at 20:24
Kevin From
asked Feb 4, 2016 at 18:16
Kevin FromKevin From
1522 silver badges10 bronze badges
1
-
You want to fade out
.vge-eksponering
and, when it's done fading out, fade in.main
? – T.J. Crowder Commented Feb 4, 2016 at 18:19
2 Answers
Reset to default 6You have (at least) two choices:
If there's only one .vge-eksponering
element, then use the pletion callback fadeOut
gives you:
$(".vge-eksponering").fadeOut(1200, function() {
$(".main").fadeIn(1200);
});
Or just use delay
with a value equivalent to the first fadeOut:
$(".vge-eksponering").fadeOut(1200);
$(".main").delay(1200).fadeIn(1200);
use setInterval
setInterval(function() {
$(".main").fadeIn(1200);
}, 1200);
a tutorial on setInterval
http://www.w3schools./jsref/met_win_setinterval.asp
本文标签: javascriptjQuery fadeOut then waitthen fadeIn doesn39t workStack Overflow
版权声明:本文标题:javascript - jQuery .fadeOut then wait, then .fadeIn doesn't work - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745653204a2161441.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论