admin 管理员组文章数量: 1086019
I am html and JavaScript newbie. here's my html code.
<div class="row" >
<button class="..." id="button">
...
</button>
<div class="..." id="box">
...
</div>
</div>
and my javascript:
$(document).read(function(){
$('#box').hide();
$('#button').click(function(){
$('#button').fadeOut('slow');
$('#box').fadeIn('slow);
}
}
In this case, I want a seamless fadein/fadeout transition effect from the button to the box , but the above code will make the button and the box coexist for a few seconds (appears as button above box), before the button disappear (Then box takes the original place of the button).
Is there any bootstrap js or customized js allow me to have the seamless transition?
PS: I've tried hide('slow') and show('slow'). They don't quite hit the mark neither :s
Thank You!!!
I am html and JavaScript newbie. here's my html code.
<div class="row" >
<button class="..." id="button">
...
</button>
<div class="..." id="box">
...
</div>
</div>
and my javascript:
$(document).read(function(){
$('#box').hide();
$('#button').click(function(){
$('#button').fadeOut('slow');
$('#box').fadeIn('slow);
}
}
In this case, I want a seamless fadein/fadeout transition effect from the button to the box , but the above code will make the button and the box coexist for a few seconds (appears as button above box), before the button disappear (Then box takes the original place of the button).
Is there any bootstrap js or customized js allow me to have the seamless transition?
PS: I've tried hide('slow') and show('slow'). They don't quite hit the mark neither :s
Thank You!!!
Share Improve this question asked May 24, 2015 at 7:03 user3013013user3013013 251 gold badge1 silver badge4 bronze badges2 Answers
Reset to default 5Show the box div in fadeOut()
plete callback function
$(document).ready(function() {
$('#box').hide();
$('#button').click(function() {
$('#button').fadeOut('slow', function() {
$('#box').fadeIn('slow');
})
});
});
<script src="https://ajax.googleapis./ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="row">
<button class="..." id="button">
...a
</button>
<div class="..." id="box">
...b
</div>
</div>
fadein and fadeout functions have callbacks where the callback is called when the fadein /fadeout pletes.
$('#button').fadeOut('slow', function() {
$('#box').fadeIn('slow');
})
Here the fadein will be called only after the fadeOut has finished.
本文标签: javascriptBootstrap Transition for fadeIn() and fadeOut()Stack Overflow
版权声明:本文标题:javascript - Bootstrap Transition for fadeIn() and fadeOut() - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744000222a2516310.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论