title: Initiate a .click function with "if/else if" statement
body: <p>Apologies for my last question being so poorly made.</p>
  
  <p>In this bit of code I am trying to have a div be able to move left and right when a button is clicked (LButton or RButton)</p>
  
  <p>What I've tried to do is have an initial variable 'click' = 0 and when the button is clicked it adds '1' to the variable. In the if statement the idea is that once the button has been clicked once, it can be clicked again if click = 1 to make the div go an extra 850 px to the left.</p>
  
  <p>This isnt the most practical way of doing this, and I'm not sure if its even semantically correct. Does anyone have a suggestion as to make this work, or perhaps a better way of getting this done?</p>
  
  <pre><code>var click=0;
  if (click === 2) {
  $(function () {
      $('.RButton').click(function (e) {
          $('.slideContain').animate({
              'margin-left': '-2550px'
          });
      });
  });
  } else if (click === 1) {
  $(function () {
      $('.RButton').click(function (e) {
          $('.slideContain').animate({
              'margin-left': '-1700px'
          }); 
      var click = (click + 1);
      });
  });
  } else if (click === 0) {
  $(function () {
      $('.RButton').click(function (e) {
      $('.slideContain').animate({
          'margin-left': '-850px'
      });
      var click = (click+1);
  });
  }
  </code></pre>