tags:

views:

28

answers:

1

jquery code

$(function(){
            $('#switcher1').click(function(){
                $(this).stop().animate({left:'35px'},800);
            });
        });

Hey everybody, this code slides #switcher1 at 35px to the right. I have question, how i can make that #switcher1 on one more click slides back to the original position ?

+1  A: 

Use toggle:

$('#switcher1').toggle(function() {
    $(this).stop().animate({left:'35px'},800);
}, function() {
    $(this).stop().animate({left:'0px'},800);
});
karim79
Yeap, It works, but there should be '0' instead of '-35px' :)Thank you )
Ah, edited that in. Sorry.
karim79