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

215
Vistas
JQuery: how to exclude from selection div elements that contain a span element?

I have selected a group of div elements from a table, filtered the selection to only the div elements that contain the class __gwt_cell, and I have saved them into an array, with this command

var myarray = $('table > tbody > tr > td > div').filter('div[__gwt_cell]')

Now I would like to exclude from this selection all the div elements that contain a span element, so all the snippets like this:

<div style="outline-style:none;" __gwt_cell="cell-gwt-uid-615" tabindex="0">
    <span class="gwt-CheckBox">
        <input type="checkbox" class="filled-in" tabindex="-1" value="on" id="gwt-uid-708"> 
        <label for="gwt-uid-708"></label>
    </span>
</div>

In order to do this, I have read this thread, reverted the syntax of the solution, and wrote this command

var myarray = $('table > tbody > tr > td > div').filter('div[__gwt_cell]').filter('div:not(div span)');

that unfortunately does not work.

How can I get the desired result?

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

0

the :has() selector is what you need

var myarray = $('table > tbody > tr > td > div').filter('div[__gwt_cell]').not('div:has(span)');

the last piece of the command, that is .not('div:has(span)') , is saying

"exclude div elements that have at least one span element as child"

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