title: JavaScript - Counting same colour cells in one row of the html table
body: <p>I have a table which is generated using javascript from image. The size of the table depends on the size of the image. It reads pixels color in rgb. Then each pixel is converted to cell. (I have such table as an example):</p>
  
  <pre><code>  &lt;table height="100" width="100"&gt;
      &lt;tbody&gt;
      &lt;tr&gt;
      &lt;td style="background-color: rgb(121,117,92);"&gt;&lt;/td&gt;
      &lt;td style="background-color: rgb(121,117,92);"&gt;&lt;/td&gt;
      &lt;td style="background-color: rgb(121,117,92);"&gt;&lt;/td&gt;
      &lt;td style="background-color: rgb(121,117,92);"&gt;&lt;/td&gt;
      &lt;td style="background-color: rgb(127,129,116);"&gt;&lt;/td&gt;
      &lt;td style="background-color: rgb(127,129,116);"&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td style="background-color: rgb(121,117,92);"&gt;&lt;/td&gt;
      &lt;td style="background-color: rgb(121,117,92);"&gt;&lt;/td&gt;
      &lt;td style="background-color: rgb(121,117,92);"&gt;&lt;/td&gt;
      &lt;td style="background-color: rgb(127,129,116);"&gt;&lt;/td&gt;
      &lt;td style="background-color: rgb(127,129,116);"&gt;&lt;/td&gt;
      &lt;td style="background-color: rgb(127,129,116);"&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Accordingly to its size, it would be perfect to minimize the html code. But i need to make also some more things on the web page with generated image:</p>
  
  <ul>
  <li>On action (for example mouse pressed on some cell), i need recognize the color of the cell. </li>
  <li>After this, check the row before and after the celected cell for the same RGB color. </li>
  <li>After this, count one color cell according to color of selected cell and give a tooltip above.</li>
  </ul>
  
  <p><strong>Simply:</strong> press cell - check color - check same cell near it in one row - count them - give tooltip with number of cells.</p>
  
  <p>Maybe there is some javascript libraries like JQuery with functions i need?</p>