Javascript jQuery查找所有选中的行
我有一张带复选框的桌子。 我需要知道检查了哪些表行, 单击“更新”按钮后Javascript jQuery查找所有选中的行,javascript,jquery,html,Javascript,Jquery,Html,我有一张带复选框的桌子。 我需要知道检查了哪些表行, 单击“更新”按钮后 <div id='ggg' style="position:absolute; bottom:0px" id=> <table class="display" id="poll"> <th>Polling</th> <th>rrd</th> <tr> <td>ping</td
<div id='ggg' style="position:absolute; bottom:0px" id=>
<table class="display" id="poll">
<th>Polling</th>
<th>rrd</th>
<tr>
<td>ping</td>
<td>10.rrd</td>
<td>
<input type="checkbox" name="myTextEditBox" value="checked"/>
</td>
</tr>
<tr>
<td>snmp</td>
<td>11.rrd</td>
<td>
<input type="checkbox" name="myTextEditBox" value="checked" />
</td>
</tr>
</table>
<form>
<input type='button' id='update' value='update'>
</form>
</div>
您可以使用:checked选择器获取选中复选框,同时使用.closesttr获取行。试试这个:
checkedrows = $('input:checked').closest('tr');
您可以使用:checked选择器获取选中复选框,同时使用.closesttr获取行。试试这个:
checkedrows = $('input:checked').closest('tr');
试试这个
$('#update').on('click',function(){
$('#poll').find('input:checked').closest('tr').css('background','green');
});
$("#update").click(function () {
$('input:checked').each(function () {
alert($(this).closest("tr").text());
});
});
试试这个
$('#update').on('click',function(){
$('#poll').find('input:checked').closest('tr').css('background','green');
});
$("#update").click(function () {
$('input:checked').each(function () {
alert($(this).closest("tr").text());
});
});
试试这个
$('#update').on('click',function(){
$('#poll').find('input:checked').closest('tr').css('background','green');
});
$("#update").click(function () {
$('input:checked').each(function () {
alert($(this).closest("tr").text());
});
});
编辑
试试这个
$('#update').on('click',function(){
$('#poll').find('input:checked').closest('tr').css('background','green');
});
$("#update").click(function () {
$('input:checked').each(function () {
alert($(this).closest("tr").text());
});
});
编辑
您可以这样使用:
如果要突出显示到tr:
如果要突出显示到td:
您可以这样使用:
如果要突出显示到tr:
如果要突出显示到td:
我不知道如何使用itI不知道如何使用您想突出显示tr或td?不,我想获得文本值,包括td或所有td的文本?您想突出显示tr或td?不,我想获取文本值,包括td或所有td的文本?@user3485339 var text=$'poll'。查找'input:checked'。最近的'tr'。文本检查此小提琴:@user3485339 var text=$'poll'。查找'input:checked'。最近的'tr'。文本检查此小提琴: