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

110
Views
How to do a jQuery selection starting from a jQuery object

In Vanilla JavaScript, one way to select an element from the DOM is:

let element = document.querySelector('[css selector]');

You can then use this element to select elements within this element, which can be done like this:

element.querySelector('[other css selector]');

I tried looking it up on jQuery's documentation, but couldn't find anything. Is there a way to do this in jQuery? Maybe something like:

let element = $('[css selector]');
element.select('[other css selector]');

// or maybe
$(element, '[other css selector]');

I know I can do this:

element[0].querySelector('[other css selector]');

But that is converting it back into a native element and then using the native JavaScript method. Is there a way to do this with only jQuery methods?

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

In jQuery you can achieve identical behavior using jQuery.find(selector) method:

let $element = $('#some-div');
let $someGrandChildren = $element.find('b, i, u');

A less common approach is to use jQuery(selector[, context ]) method where the context argument could be a DOM Element, Document, jQuery or selector. So this works as expected too:

let $element = $('#some-div');
let $someGrandChildren = $('b, i, u', $element);

According to the documentation, this method uses .find() behind the scene.

about 4 years ago · Santiago Gelvez Report

0

$('#thefirstselector .yoursecond .yourthird #fourth');
about 4 years ago · Santiago Gelvez 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!