title: how to toggle css via jquery with the .css function
body: <p>the function is triggered via a button so I thought every time you push it will check x set the  background accordingly and put x in the other state so the next push gives the other result</p>
  
  <p>I just saw that I can use the .css in an .toggle but I'm still curious why my solution wont work</p>
  
  <pre><code>var x = 0;
  
  function toggledark(x){
      if (x == 0) {
          $('body').css({'background-color': 'red'});
          x+=1;
          return x;
      }
      else {
          $('body').css({'background-color': 'black'});
          x-=1;
          return x;
      }
  }
  </code></pre>
  
  <p>I thought it will toggle but I only get black and it stays this way</p>