sradha sradha - 26 days ago 4x
jQuery Question

How to remove multiple tr simultaneously in jQuery without using for loop

I can do this, simply doing it in for loop, but I need to do it without using loop.

Is there any way to make it possible?
Below I am writing some of my code:

function submitFormArchive(Status) {
var siteUrl = $("#pageurl").val();
var myCheckboxes = new Array();
$("input[type='checkbox'][name='archive[]']:checked").each(function () {
alert(myCheckboxes);///this one i am getting dynamic ids
type: 'POST',
url: siteUrl + 'Appadmins/ajaxUpdateArchive',
data: {"myCheckboxes": myCheckboxes, "status": Status},
success: function (data) {

return false;

<tr class="message_box" id='remove-id-<?php echo $list->id;?>'></tr>

This one in for loop

I am posting some part of codes.

$("#remove-id-" + myCheckboxes).slice(myCheckboxes).remove();

Is there any for multiple, maybe I have written wrong in this above code.


Try the code below

$("input[type='checkbox'][name='archive[]']:checked").each(function() {


alert(myCheckboxes); //40,39,38 //it can be any id ,as i made it dynamic .

// construct array of IDs here
var ids = { return "#remove-id-" + id; });
// ["#remove-id-40", "#remove-id-39", "#remove-id-38"]

// concat all id selectors together using comma `,` 
var idSelector = ids.join(",");
// "#remove-id-40,#remove-id-39,#remove-id-38"

// remove all at once.