I've a simple problem with jQuery, checkout this: http://jsfiddle.net/4Q5uQ/
How to fadeIn() the box after the fadeOut() effect is completed?
I've a simple problem with jQuery, checkout this: http://jsfiddle.net/4Q5uQ/
How to fadeIn() the box after the fadeOut() effect is completed?
I think you want two things:
<div>
s should be in the same place so they don't move around.<div>
and then fade in the other <div>
.The first can be done by wrapping the two <div>
s in a relatively positioned <div>
and then absolutely positioning the inner <div>
s:
<div class="wrapper">
<div id="div_1" data="1" class="box">
test_1
</div>
<div id="div_2" data="2" class="box">
test_2
</div>
</div>
And:
div.wrapper {
position: relative;
}
div.box {
/* ... */
position: absolute;
top: 0;
left: 0;
right: 0;
}
The second is just a matter of adding :visible
to your fadeOut
selector:
$(".box:visible").fadeOut(1000, ...
Updated fiddle: http://jsfiddle.net/ambiguous/jAP2b/
Following code may be your need: http://jsfiddle.net/4Q5uQ/5/
$(document).ready(function() {
$("a").click(function() {
var fin = $(this).attr('fin');
var fout = $(this).attr('fout');
$("#div_" + fout).show();
$("#div_" + fin).hide();
$(".box[data=" + fout + "]").fadeOut(4000, function() {
$(".box[data=" + fin + "]").fadeIn(4000);
});
});
});