用jQuery读取HTML表格的第一列值 [英] Read the first column values of a HTML table with jquery
本文介绍了用jQuery读取HTML表格的第一列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到一张表:
I got a table:
<table id="ItemsTable" >
<tbody>
<tr>
<th>
Number
</th>
<th>
Number2
</th>
</tr>
<tr>
<td>32174711</td> <td>32174714</td>
</tr>
<tr>
<td>32174712</td> <td>32174713</td>
</tr>
</tbody>
</table>
我需要将值32174711和32174712以及列号的每个其他值存入数组或列表中,我使用jquery 1.8.2。
I need the values 32174711 and 32174712 and every other value of the column number into an array or list, i'm using jquery 1.8.2.
推荐答案
var arr = [];
$("#ItemsTable tr").each(function(){
arr.push($(this).find("td:first").text()); //put elements into array
});
查看此链接进行演示:
这篇关于用jQuery读取HTML表格的第一列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文