【发布时间】:2018-08-27 00:53:39
【问题描述】:
我已经使用 jQuery 成功实现了<table> <tr> 点击事件,其中我使用以下 .taglib-search-iterator 获取所选行的所需<td> 的值是我的表class,
$(".taglib-search-iterator tbody").on("click", "tr", function(e){
alert($(this).find("td").eq().html());});
但根据我的要求,我需要忽略 table 的第一行 <tr> 和 倒数第二个 和 last 列 <td>的表。为此,我做了以下工作,
$(".taglib-search-iterator tbody tr:not(:first-child) td:not(:nth-last-child(2))").click(function(){
alert('Right position clicked');
});
现在我的问题是当点击事件被触发时,我无法在第 7 列检索<td> 的值。
我已经关注了
alert($(this).eq(7).html());
但它返回 undefined。我也尝试过简单地使用
alert($(this).html());
它正在返回我点击的<td> 的值。
问题?
如何检索特定<td> 的值?
添加,<td> ,<tr> 是自动生成的,因此它与动态 class 和 id 相关联,因此无法使用。
【问题讨论】:
标签: javascript jquery html-table