gpt4 book ai didi

javascript - 使用 jQuery 获取表中的列 id

转载 作者:行者123 更新时间:2023-11-28 15:10:24 27 4
gpt4 key购买 nike

我有这个表结构。

<table id = "table1">
<thead>
<tr id = "header_row">
<th> <a id = "a1">ABC</a> </th>
<th> <a id = "a2">DEF</a> </th>
<th> <a id = "a3">GHI</a> </th>
<th> <a id = "a4">JKL</a> </th>
</tr>
</thead>
<tr>.....data filling up the table.....</tr>
<tr>.............</tr>
.
.
</table>

所以我想从这个表中获取值“a2”,你能告诉我该怎么做吗?谢谢!

编辑:还有很多其他<a> <table>页面上有标签,那么有没有办法利用id来提取呢?

最佳答案

So from this table, I want to fetch the value "a2"

您的意思是获取标题行中第二列的 ID?

试试这个

$("#header_row th a:eq(1)").attr("id")

如果您只是想根据已知aid获取ABC,那么

$("#a2").html(); //or text()

关于javascript - 使用 jQuery 获取表中的列 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36710953/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com