title: How to get table cell values any where in the table using jquery
body: <p>I have the following table that returns the each cell value when clicked using javascript?</p>
  
  <p>How can i do the same using jquery? </p>
  
  <pre><code> &lt;script language="javascript"&gt;
  
          var tbl = document.getElementById("tblMain");
          if (tbl != null) {
              for (var i = 0; i &lt; tbl.rows.length; i++) {
                  for (var j = 0; j &lt; tbl.rows[i].cells.length; j++)
                      tbl.rows[i].cells[j].onclick = function () { getval(this); };
              }
          }
  
          function getval(cel) {
              alert(cel.innerHTML);
          }
      &lt;/script&gt;
  
  &lt;table align="center" id="tblMain" border="1" style="cursor: pointer;"&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  R1C1
              &lt;/td&gt;
              &lt;td&gt;
                  R1C2
              &lt;/td&gt;
              &lt;td&gt;
                  R1C3
              &lt;/td&gt;
              &lt;td&gt;
                  R1C4
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  R2C1
              &lt;/td&gt;
              &lt;td&gt;
                  R2C2
              &lt;/td&gt;
              &lt;td&gt;
                  R2C3
              &lt;/td&gt;
              &lt;td&gt;
                  R2C4
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  R3C1
              &lt;/td&gt;
              &lt;td&gt;
                  R3C2
              &lt;/td&gt;
              &lt;td&gt;
                  R3C3
              &lt;/td&gt;
              &lt;td&gt;
                  R3C4
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  R4C1
              &lt;/td&gt;
              &lt;td&gt;
                  R4C2
              &lt;/td&gt;
              &lt;td&gt;
                  R4C3
              &lt;/td&gt;
              &lt;td&gt;
                  R4C4
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  </code></pre>