gpt4 book ai didi

jquery-ui - 通过单击该行的按钮,使用 jquery 获取行数据

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

如果选择了按钮,我在获取行中的表数据时遇到问题。我有两个按钮批准和拒绝,根据用户单击的按钮,我想使用查询来获取数据。可以获取行号和其他内容,但不能获取行数据。我需要获取 id 和测试人员。

这就是我所拥有的

<table id="mytable" width="100%">
<thead>
<tr>
<th>ID</th>
<th>Tester</th>
<th>Date</th>
<th>Approve</th>
<th>Deny</th>
</tr>
</thead>
<tbody>
<tr class="test">
<td class="ids">11565 </td>
<td class="tester">james</td>
<td>2012-07-02 </td>
<td><Button id="Approved" type="submit" >Approved</button>
</td>
<td><Button id="deny_0" type="submit" >Denied</button>
</td>
</tr>
</tbody>
</table>

这是我的 javascript,用于获取 tr 和 td 号码,但我不知道如何使用它来获取我需要的内容

$(document).ready(function() {  

/*$('#cardsData .giftcardaccount_id').each(function(){

alert($(this).html());
}); */
$('td').click(function(){
var col = $(this).parent().children().index($(this));
var row = $(this).parent().parent().children().index($(this).parent());
alert('Row: ' + row + ', Column: ' + col);
// alert($tds.eq(0).text());
console.log($("tr:eq(1)"));
// $("td:eq(0)", this).text(),

});


});

最佳答案

$(document).ready(function(){
$('#Approved').click(function(){
var id = $(this).parent().siblings('.ids').text();
var tester = $(this).parent().siblings('.tester').text();

console.log(id);
console.log(tester);
});
});​

JSFiddle

关于jquery-ui - 通过单击该行的按钮,使用 jquery 获取行数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11302738/

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