温馨提示×

jquery如何获取指定列

养鱼的猫咪
237
2021-05-19 11:54:24
栏目: 编程语言

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

jquery如何获取指定列

具体步骤如下:

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($("table tr").find("td:eq(0)")); //获取表格的第一列

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

});

0