jquery如何获取指定列

lewis 2019-03-09 25次阅读

使用jquery获取指定列的方法:1.新建html项目,引入jquery;2.创建table表格;3.通过标签名获取表格对象,使用find()方法获取指定列;

具体步骤如下:

1.首先,新建一个html项目,并在项目中引入jquery;

<script type="text/javascript" src="/static/jquery-2.1.4.min.js"></script>

2.引入jquery后,在项目中创建一个table表格;

<table>

<tr>

<td></td>

<td></td>

</tr>

<tr>

<td></td>

<td></td>

</tr>

</table>

3.最后,table表格创建好后,通过标签名获取表格对象,在使用find()方法即可获取指定的列;

$(function(){

console.log($("tabletr").find("td:eq(0)"));//获取表格的第一列

console.log($("tabletr").find("td:eq(2)"));//获取表格的第三列

});



发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。