如何访问td中的div类,该div位于表中的tbody内的tr内

时间:2014-02-14 11:48:33

标签: jquery html css

<tbody id="records">
<tr >
<td>12</td>
<td>20</td>
<td>30</td>
<td>40</td>                       
</tr>
<tr>
<td>10</td>
<td>20</td>
<td>30</td>
<td>40</td>                            
</tr>
</tbody>

如何访问每个第三个表td,并使用javascript检查该td是否包含数字或字符串。在这所有我的td都有数字。

2 个答案:

答案 0 :(得分:2)

尝试,

$('#records tr td:nth-child(3)').each(function(){

 // do your check here.

})

DEMO for understanding

答案 1 :(得分:0)

var check= true;
$('#records tr td:nth-child(3)').each(function(){
if(isNaN($(this).html())){
check=false;
}
});
alert(check);

For Demo Click here