Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iterate through second columns in a table in jQuery

I have table in the dom that looks like this

<div id="table">
<table>
<tr>
  <td>a</td>
  <td>b</td>
  <td>c</td>
  <td>d</td>
</tr>
<tr>
  <td>a</td>
  <td>b</td>
  <td>c</td>
  <td>d</td>
</tr> 
</div>

I want to iterate through this table, such as $('#table').each(function(){}) but I only want to iterate through the second column. So the ones which in this example have a value of b.

Any ideas how to do this?

Thank you!

like image 367
dzm Avatar asked Jan 24 '13 03:01

dzm


1 Answers

Try this:

$("table tr td:nth-child(2)").each(function () {

});
like image 76
phnkha Avatar answered Oct 05 '22 10:10

phnkha