-3

I have three popups in my website. When the user click on something, the first popup open with a div in it.

If the user click on this div, the popup is closed, and open a new one. In this new popup it is the same, i have a div, and if the user click on it, it will close the second popup and open the third one.

What i am trying to do is, when you are at the third div, if you click in the close button, it will return to the second div. And if you click again in the close button, you will return to the first popup.

Is there any method in jquery to do this?

user3629180
  • 27
  • 10

1 Answers1

2

did you try to use booleans ?

for example : ( http://jsfiddle.net/KNch9/ )

var checkPOP2 = false;  

$("#pop1").click(function(){
 $(this).css("display", "none");
 $("#pop2").css("display", "initial");
});

$("#pop2").click(function(){
  if(!checkPOP2){
    $(this).css("display", "none");
    $("#pop3").css("display", "initial");
    checkPOP2 = true;
  }

  else if(checkPOP2){
    $(this).css("display", "none");
    $("#pop1").css("display", "initial");
    checkPOP2 = false;
  }
});

$("#pop3").click(function(){
  $(this).css("display", "none");
  $("#pop2").css("display", "initial");
});

Hope it can help you.

Vincent Loy
  • 83
  • 1
  • 7