lundi 18 mai 2015

Jquery's if statement for a css file

As you see in the code, I have a variable which is supposed to be incremented by 1 on every click, and then, a scenario will run based on the value of variable. Sadly, it seems like something goes definitely wrong. All 5 scenarios are running on first click.

$(document).ready(function(){
  var count = 0;
  $("#slide_control").click(function(){
    count ++;
    if (count = 1){
      $("#train_div").animate({left: '250px'});}
    if (count = 2){
      $("#train_div").animate({left: '500px'});}
    if (count = 3){
      $("#train_div").animate({left: '750px'});}
    if (count = 4){
      $("#train_div").animate({left: '1000px'});}
    if (count = 5){
      $("#train_div").animate({left: '0px'})
      count = 0;
      ;
    }    
  });   
});

Aucun commentaire:

Enregistrer un commentaire