I have a big green box using <div>
, and I have two more smaller divs called red and blue.
When someone clicks on green box, I want the red box to slide up at the same time blue box slides down.
And then when someone clicks on the green box, the red box should slide down and green box should slide up.
I have written this basic scripts, but when I click on the green box, both the red box and the green box will slide up at the same time.
How can make it so that one goes up and the other goes down at the same time?
CSS:
.block {
position: absolute;
left: 23px;
top: 34px;
width: 500px;
height: 360px;
z-index: 1;
background-color: #0F0;
}
.top-box {
background-color: #F00;
height: 179px; width: 499px;
z-index: 50;
}
.top-down {
background-color: #00F;
height: 179px;
width: 499px;
z-index: 50;
}
.bottom-box {
background-color: #06F;
height: 179px;
width: 499px;
}
#red {
position: absolute;
left: 266px;
top: 399px;
width: 494px;
height: 138px;
z-index: 2;
}
#blue {
position: absolute;
left: 26px;
top: 35px;
width: 494px;
height: 138px;
z-index: 2;
}
JavaScript:
$(".block").click(
function(){
$(".top-box").slideUp('fast');
},
function(){
$(".top-down").slideDown('slow');
});
});
HTML:
<div class="block">
testing on green
<div class="top-box" id="red">
<div class="top-down" id="blue">
</div>
</div>