bob123
bob123

Reputation: 21

jquery div swap

How can I make it so when you click the 2nd time it will go back? I guess I gotta somehow find the active one but not sure.

$("#test").click(function(){
    $("#dsa").fadeOut()
    $("#asd").fadeIn()
  });

Upvotes: 1

Views: 1121

Answers (2)

Felix Kling
Felix Kling

Reputation: 816262

Just use .toggle():

$("#test").click(function(){
    $("#dsa, #asd").toggle(400);
});

Upvotes: 2

Ólafur Waage
Ólafur Waage

Reputation: 69981

You looking for something like toggle() ?

Upvotes: 3

Related Questions