Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 557935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:04:44+00:00 2026-05-13T12:04:44+00:00

I’ve often wondered about the use of selectors versus equivalent functions in jQuery. By

  • 0

I’ve often wondered about the use of selectors versus equivalent functions in jQuery. By this I mean statements that comprise the same components that return identical result sets, but are constructed differently.

Take the following example:

alert($("#FundManager1>option").length);
alert($("#FundManager1").find("option").length);

(Note: the intention is for two equivalent queries – If these are not always the same, I would be grateful if you could point this out)

So, given the example above, is there any real difference in speed/performance? Obviously, the former is shorter, so will result in fewer uploaded/downloaded bytes, but I’m not really interested in that at the moment.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:04:45+00:00Added an answer on May 13, 2026 at 12:04 pm

    I would say the first is faster, as it parses only one CSS selector and only looks for children, where the second one has to parse two, plus has to look for all descendants.

    But I wouldn’t bother for something so small. As JavaScript is really fast in WebKit and Gecko, and still relatively fast in IE, no-one will ever notice the difference.


    From what I can see by looking at the jQuery/Sizzle source, both pieces of code do the same internally.

    First document.getElementById('FundManager1') is executed (Sizzle is smart enough to know that’s what #FundManager1 means), and then the search for option is done using that as context. The only difference between the two pieces of code is the use of the > selector, causing Sizzle to search for just the context’s direct children, and not all descendants. I assume this faster, as only one level of DOM hierarchy has to be explored.


    Another edit:

    The text above only applies to browsers that don’t support the document.querySelectorAll(css_selector) method! In browsers that do (WebKit and Gecko, maybe Opera?) this method is used instead of Sizzle, so that all CSS selector parsing is done by the browser itself, instead of the jQuery framework, which I’m sure is a lot faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.