Get <td> element value inside a <table>

1) Using JQuery.....

$('#tableDivId tr').each(function() {
    var tdText = $(this).find("td:first").html();    

Here you are iterating all rows of a table according to given div id, and then you are fetching first <td> element data for current <tr>....

2) Without JQuery...............

function loadAllTDs(){
var table = document.getElementById('tableDivId'); 
var rows = table.getElementsByTagName('tr');
var cells, tdText;

for (var i = 0, j = rows.length; i < j; ++i) {
      cells = rows[i].getElementsByTagName('td');
      if (!cells.length) {
      tdText = cells[0].innerHTML;  // For 0th td for each tr of this table....

Popular posts from this blog

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Session timeout interceptor in struts 2