how to retrieve all row selected checkboxes of a table as list in Jquery?
how to retrieve all row selected checkboxes of a table as list and add these elements to another table in Jquery?
many th开发者_开发百科anks
Its hard to say specifically without your markup but:
var checked = $(':checked');
will get you all the checked inputs. if you want the values in an array you could do:
var values = $(':checked').map(function(ele,idx){
return $(ele).val();
});
or if you want the field names:
var values = $(':checked').map(function(ele,idx){
return $(ele).attr('name');
});
You could try using the jQuery.each() function
$('#row input:checked').each(function(){
// Do your adding to the other table inhere for each checkbox :)
});
Many thanks! I've got it :-)! I did it like this:
$('input[type=checkbox]').each(function(){
if ($(this).is(':checked')) {
var obj_id = $('#tbodyMapNotUsed :checked').parents("tr");
if( $('#tbodyMap').length > 0){
$(obj_id).clone(true).insertAfter('#tableMap tbody>tr:first');
}
else{
$('#tableMap').append($('<tbody id="tbodyMap"><tr></tr>'));
$(obj_id).clone(true).insertAfter('#tableMap tbody>tr:first');
$('#tableMap').append($('</tbody>'));
}
$(obj_id).clone(true).insertAfter('#tableMapAll tbody>tr:first');
$(obj_id).remove();
}
});
精彩评论