I'm sure this is quite a simple thing to do, but I can't work it out for the life of me...
I have 2 divs; #uniwork & #personalwork which are in the exact same places. I also have 2 buttons #university & #personal, and when I click on the relevant button the div is animated to slide down.
The Problem I am having is when I press the #university button the #uniwork div slides down perfectly, the same applies with pressing #personal and the #personalwork div, but what I need is for the opposite one to reverse the animation and go back up before the actual div for that button comes down.
Example; Press #university, #uniwork slides down, Press #personal, #uniwork slides back up, #personalwork slides down. Press #university again, #personalwork slides up, #uniwork slides down...etc
The code which I have is working perfectly for the divs to slide down and back up for that pacific button and div, but I can't figure out how to get the opposing div to go back up. I'm not sure whether an 'If' 'else' statement would be more appropriate, but as I'm a beginner this is proving very difficult. I did try the .slide but the effect wasn't right, I prefer the actual div moving rather than the revealing effect.
The Jquery which is working to a degree;
$("#university").toggle(function(){
$("#uniwork,").animate({top:"0"},{duration:300});
}, function() {
$("#uniwork").animate({top:"-330px"},{duration:300});
});
$("#personal").toggle(function(){
$("#personalwork").animate({top:"0"},{duration:300});
}, function() {
$("#personalwork").animate({top:"-330px"},{duration:300});
});
I have also made a mockup on JSfiddle, but on my actual website design the two are sitting onto of each other;
Mockup
Thank you in advance

New Topic/Question
Reply


MultiQuote



|