user313271
user313271

Reputation: 71

jquery animate question

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 ?

Upvotes: 2

Views: 111

Answers (1)

karim79
karim79

Reputation: 342765

Use toggle:

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

Upvotes: 2

Related Questions