title: jquery css continous rotate by 90 degrees on each button press
body: <p>I have found a solution that partially fits my needs. When pressing a button I need a div to rotate 90 degrees, on next press 90 degrees more etc. And i need another button which would rotate it in the opposite direction the same way. I found a JavaScript Fiddle and slightly modified it, but the problem is that on the button press the div would revert to its original position before each rotate. So its not possible to rotate it more than 90 degrees. How do I fix this? The second question is why would it rotate only once, if I change broderSpacing from "-90" to "90" (button works only once then nothing happens on click)?</p>
  
  <p><a href="http://jsfiddle.net/skunksts/HwTMb/1130/" rel="noreferrer">JSFIddle</a></p>
  
  <p>HTML</p>
  
  <pre><code>&lt;div id="foo"&gt;Text&lt;/div&gt;
  &lt;button onclick="rotateFoo()"&gt;rotate&lt;/button&gt;
  </code></pre>
  
  <p>CSS</p>
  
  <pre><code>#foo {
      width:100px;
      height:100px;
      position:absolute;
      top:100px;
      left:100px; 
      border-spacing: 0;
      background-color:red;
  }
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>function rotateFoo(){
      $('#foo').animate({borderSpacing: -90}, {
      step: function(now,fx) 
      {
        $(this).css('-webkit-transform','rotate('+now+'deg)'); 
        $(this).css('-moz-transform','rotate('+now+'deg)');
        $(this).css('transform','rotate('+now+'deg)');
      },
      duration:'slow'
      },'linear')
  
  }
  </code></pre>