title: jQuery click / toggle between two functions
body: <p>I am looking for a way to have two separate operations / functions / &quot;blocks of code&quot; run when something is clicked and then a totally different block when the same thing is clicked again. I put this together. I was wondering if there was a more efficient / elegant way. I know about jQuery <a href="http://api.jquery.com/toggle" rel="nofollow noreferrer">.toggle()</a> but it doesn't work as desired.</p>
  <p>Working here:
  <a href="http://jsfiddle.net/reggi/FcvaD/1/" rel="nofollow noreferrer">http://jsfiddle.net/reggi/FcvaD/1/</a></p>
  <pre><code>var count = 0;
  $(&quot;#time&quot;).click(function() {
      count++;
      //even odd click detect 
      var isEven = function(someNumber) {
          return (someNumber % 2 === 0) ? true : false;
      };
      // on odd clicks do this
      if (isEven(count) === false) {
          $(this).animate({
              width: &quot;260px&quot;
          }, 1500);
      }
      // on even clicks do this
      else if (isEven(count) === true) {
          $(this).animate({
              width: &quot;30px&quot;
          }, 1500);
      }
  });
  </code></pre>