title: Trim white space in table cell
body: <p>Would love it if I could get some help on how to remove white space in the beginning and end of a table cell.  The following compares two cell, if different the newCell is highlighted in gray.  It partially works, except I need to trim the whitespace.  </p>
  
  <p>Any help would be greatly appreciated.  Thanks!</p>
  
  <p>This needs to work in IE8 so I applied the following in the to head section:</p>
  
  <pre><code>if (!String.prototype.trim) {
      String.prototype.trim = function () {
      return this.replace(/^\s+|\s+$/g, '');
      }
  }
  </code></pre>
  
  <p>Code on the page:</p>
  
  <pre><code>$(".data table tbody tr.row").each(function () {
          $(this).find('td').each(function (index) {
              var oldCell = $(this);
              var newCell = $(this).next('td').length &gt; 0 ? $(this).next('td') : null;
              if (index % 2 == 0 &amp;&amp; newCell &amp;&amp; oldCell.text().trim !== newCell.text().trim) {
                  oldCell.css('backgroundColor', '#FFF');
                  newCell.css({
                      'backgroundColor': '#666',
                      'color': '#FFF'
                  });
              }
          });
      });
  </code></pre>