title: Trying to bind click action on table td
body: <p>I'm trying to add a click action to the cells of an html table.</p>
  
  <p>Here's my Javascript : </p>
  
  <pre><code>$(document)
      .ready(
  
  function () {
      function setColor(cell) {
          var cssRed = {
              "color": '#ff0000'
          }
          var cssBlue = {
              "color": '#0000ff'
          }
          if (cell.css('color') == '#ff0000') cell.css(cssBlue);
          else cell.css(cssRed);
      }
      $('td').click(function () {
          setColor($(this));
      });
  });
  </code></pre>
  
  <p>And here's my HTML</p>
  
  <pre><code>    &lt;table style="text-align: center" border='1'&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Data&lt;/td&gt;
              &lt;td&gt;Data&lt;/td&gt;
              &lt;td&gt;Data&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Data&lt;/td&gt;
              &lt;td&gt;Data&lt;/td&gt;
              &lt;td&gt;Data&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Data&lt;/td&gt;
              &lt;td&gt;Data&lt;/td&gt;
              &lt;td&gt;Data&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Which is supposed to change the color of the text within the clicked cell. I'm trying to make something similar to the grid in <a href="http://whenisgood.com" rel="nofollow noreferrer">http://whenisgood.com</a> </p>
  
  <p>Although, for some reason, it keeps entering the <code>else</code> statement of the if (in the <code>setColor</code> method). So apparently this comparison <code>cell.css('color') == '#ff0000'</code> fails every time. What did I do wrong here?</p>
  
  <p>edit: I made an alert of the <code>cells.css('color')</code> and here's the output : 
  at first <code>rgb(11,4,0)</code></p>
  
  <p>and then after clicking a second time : <code>rgb(255,0,0)</code></p>
  
  <p>edit2: At first I tried assigning the colors as <code>blue</code> and <code>red</code> literally. However it wouldn't work (even if I was comparing with <code>blue</code> and <code>red</code>). I guess Javascript won't marshall <code>red</code> in Hex or RGB, right?</p>
  
  <p>edit3: If you downvote, please let me know why, I'll try to update the question so it gets better.</p>