Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
Trying to remove checkboxes from specific table rows

I'm trying to add checkboxes to a table using Javascript and then remove them from totals columns (that have class "kn-table-totals"). However, my code removes all of the checkboxes. I have a table that displays some data and totals the values at the bottom. I'd like the checkboxes at the start of each data set but not the in the totals columns. See the fiddle below. Heres my code:

$('#' + view.key + '.kn-table tbody tr').each(function() {
    $(this).prepend('<td><input type="checkbox"></td>');
});
   $('#' + view.key + '.kn-table tbody tr.kn-table-totals td input').each(function() {
    $(this).remove()
}

Here's one of the checkboxes I'm trying to target:

<tr class="kn-table-totals">
<td style="background-color: rgb(238, 238, 238); border-top: 1px solid rgb(218, 218, 218); text-align: right;">
<strong>Totals - 
<input type="checkbox">
</strong>
</td>

The full code is here: https://jsfiddle.net/rainybird/50wya2k7/1/

Any help would be appreciated!

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You will have to check for unique identifier eg. checkbox value or id.

Example:

Using value <input type="checkbox" value="value1">

$(`#${view.key}.kn-table tbody tr.kn-table-totals td input[value='value1']`).remove();

Using id <input type="checkbox" id="uniqueId">

$(`#${view.key}.kn-table tbody tr.kn-table-totals td input#uniqueId`).remove();
about 4 years ago · Juan Pablo Isaza Denunciar

0

However, my code removes all of the checkboxes

Nope nothing is removed. The checkboxes will never added. This is because you have a typo in your code. The .each() closing bracket ) is missing.

Change

$('#' + view.key + '.kn-table tbody tr.kn-table-totals td input').each(function() {
    $(this).remove()
}

To this instead

$('#' + view.key + '.kn-table tbody tr.kn-table-totals td input').each(function() {
    $(this).remove()
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda