Answers for "how to loop through td jquery"

1

jquery for each tr in td

// tr is the jquery object
$(tr).find('td').each (function (index, td) {
  console.log(td)
});

// for each tr get each td

$('#tableContent tr').each(function(index, tr) {
  $(tr).find('td').each (function (index, td) {
    console.log(td)
  });
});
Posted by: Guest on February-03-2021
0

iterate table in jquery

<table id="myTable" style="margin-left:50px;">
  <tr><th>Sr no</th><th>Name</th><th>Gender</th><th>Location</th></tr>
  <tr><td> 1</td><td>Satinder Singh</td><td> M </td><td> India </td></tr>
  <tr><td> 2 </td><td>Amit Sarna</td><td> M </td><td> France </td></tr>
  <tr><td> 3 </td><td>Andrea Ely</td><td> F </td><td> Brazil </td></tr>
  <tr><td> 4 </td><td>Leslie Mac </td><td> F </td><td> Australia </td></tr>
  <tr><td> 5 </td><td>Sonya David </td><td> F </td><td>America</td></tr>
</table>
Posted by: Guest on January-29-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language