Link to home
Start Free TrialLog in
Avatar of derrida
derrida

asked on

animate a dir right position like toggle

Hi
i have a div that start like so:
right: -50%;

Open in new window


i need to toggle it to:
right: -90%;

Open in new window


i tried toggle but it doesn't just move it, it is like hide and show. i just need to toggle its right between these two points.
so i have this, and it works but it doesn't act like a toggle:
$('#menu-btn').on("click",function(e) {
 $('.slide').animate({"right": '-90'});
});

Open in new window


what am i missing here? how to make it act like a toggle?

best regards
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Hi,

please try this:
$('#menu-btn').on("click",function(e) {
 if ($('.slide').css('right') == '-90%') {
	$('.slide').css('right') = '-50%';
 } else {
	$('.slide').css('right') = '-90%';
 }
});

Open in new window


Which jQuery version are you using?

HTH
Rainer
ASKER CERTIFIED SOLUTION
Avatar of derrida
derrida

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial