gpt4 book ai didi

jquery - 确定用户单击的列/行

转载 作者:行者123 更新时间:2023-12-01 00:00:21 25 4
gpt4 key购买 nike

使用 JQuery,我需要知道用户是否单击了链接或第三列,并且需要获取第一列中变量的值。我该怎么做?

我的html:

<div id="test">
<table id="tablex" cellpadding="0" cellspacing="0" border="0" class="display">
<thead>
<tr>
<th>Cod</th>
<th>Name completo</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John Foster 1</td>
<td><img entity_id="1" class="image-selector" src='imagens/grid_cancel.png' title='' /></td>
</tr>
</tbody>
</table>

我的 jQuery:

$("#tablex tbody").on("click", "td", function(event){
alert($(this).text());
});

最佳答案

$("#tablex tbody").on("click", "td", function(event){
alert($(this).index());
alert($(this).siblings("td:first").text());
});

$(this).index() 将为您提供单击列的从零开始的索引。$(this).siblings("td:first").text() 将为您提供第一列中的文本。

在这里,拉一下 fiddle :http://jsfiddle.net/adrianonantua/EAEsG/

关于jquery - 确定用户单击的列/行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13163510/

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