Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!