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 3242436
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:18:55+00:00 2026-05-17T18:18:55+00:00

Quick question, is a jQuery child selector without a parent ever valid? If so,

  • 0

Quick question, is a jQuery child selector without a parent ever valid? If so, how would you use it?

Example of the jQuery child selector:

$('ul > li')

Example of jQuery child selector without parent:

$('> li')

The second example above doesn’t work. However I can’t remember if I saw it in the past before or I’ve seen something advance like:

$('ul').not('>li')

Doesn’t really work either (but doesn’t pop up an error message, so it’s just ignored?)

So my question is would you EVER use a child selector without a parent, and have it be a valid jQuery selector.

Thanks, sorry if question is dumb. 🙂


Edit:

Along with Nick’s jQuery.find example on the bottom, another use case is

$('ul:has(>li)')

Note: that $(‘ul’).has(‘>li’) is wrong and should be written

$('ul').has('ul>li')

AND for not()

Not sure if I have it correct, but you wouldn’t ever use a > inside of not() directy because not() only concern about one element, while > compares multiple elements. However you can do something like

$('li:not(:has(>p))'
  • 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-17T18:18:55+00:00Added an answer on May 17, 2026 at 6:18 pm

    Yes it works without a parent, but it can’t be on the default context, because your <li> isn’t a direct child of a document. Also, it wouldn’t make any sense by itself really, since it’s a direct child of something, it’d be the same as $("li").

    When would it be used? possibly to cut down on code, for example:

    $(this).find("> li > span a");
    //as opposed to not being able to start with it:
    $(this).children("li").children("span").find("a");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

quick question, is it secure to use the jQuery.post function in jQuery to pass
Quick and silly jQuery selector question. Why this does not work : jsFiddle demo
quick question. I am trying to use either javascript, jquery, or php to make
I have a quick question of how I can use jQuery tabs (you click
Just a quick question... I currently have the following jQuery code with a selector
I've a quick question. To call an action through jQuery (to use AJAX), do
Quick jQuery selector question : I need to get the content of the first
Quick question : how do I call jQuery's animate() without any easing parameters? e.g.
Quick question: How can I use good, old jQuery Validate to validate a form
A quick question on how to use Jquery.deferred to make a slow synchronous function

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.