如果选择了一个按钮,我有问题要在行中获取表数据.我有两个按钮批准和拒绝,并根据用户点击的按钮,我想使用查询获取数据.可以得到行号和东西而不是行数据.我需要得到身份证和测试员.
这就是我所拥有的
<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>
Run Code Online (Sandbox Code Playgroud)
这是我的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(),
});
});
Run Code Online (Sandbox Code Playgroud)
$(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);
});
});?
Run Code Online (Sandbox Code Playgroud)
$(function(){
$('button').on('click', function(){
var tr = $(this).closest('tr');
var id = tr.find('.ids').text();
var tester = tr.find('.tester').text();
alert('id: '+id+', tester: ' + tester);
});
});?
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18311 次 |
| 最近记录: |