Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda