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

  • Home
  • SEARCH
  • 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 1082755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:20:44+00:00 2026-05-16T22:20:44+00:00

Using jQuery 1.4.2 (IE8 in compatibility mode) Given the following structure: <div id=’something’>something</div> <div

  • 0

Using jQuery 1.4.2 (IE8 in compatibility mode)

Given the following structure:

<div id='something'>something</div>
<div id='parental'>
    <div><p>hi there</p> goats</div>
    <p>hello again</p>
</div>
<div> end of the line</div>

and this code:

var Fred= $('#parental');
$('div').css({color: 'blue'});
Fred.children('div').css({color: 'red'});
Fred.children('div').children('p').css({color:'green',border:'solid red 2px'});
Fred.children('div p').css({color: 'orange'});
Fred.children('div>p').css({border:'solid #FFFF00 2px'});
  • “something” and ” end of the line” are blue as I would expect
  • “goats” is red as I would expect.
  • “hi there” is green with red border (I expected it to be orange/yellow border)
  • “hello again” is orange with yellow border (not what I expected).

Why do the Fred.children('div p') selector and the Fred.children('div').children('p') and Fred.children('div>p') not select the same thing?

See it in action here: http://jsfiddle.net/bxAzN/

  • 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-16T22:20:44+00:00Added an answer on May 16, 2026 at 10:20 pm

    Because .children() does the following:

    Get the children of each element in the set of matched elements, optionally filtered by a selector.

    Now take div p. The only children of #parental are a div and a p element. .children('div p') only matches the p element as it has a div as ancestor (#parental itself). But the div child clearly not matches this selector.
    You should think about children() as get all children filtered by this selector which is different from get all descendants that match this selector. For this you would have to use find().

    Fred.children('div').children('p') in contrast first takes all div children of Fred and then selects all the div‘s p children.

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

Sidebar

Related Questions

Using jQuery in IE8, I'm creating a div with a class (ex. <div class=className></div>
When using jQuery to insert HTML into a div in IE8, IE8 strips the
I have a JQuery (using JQuery 1.4.2) problem that exhibits only in IE8 in
Using jQuery, I am trying to capture and display the value of a div
Using jQuery, how do you check if there is an option selected in a
Using jQuery, is there a way to select all tag that reference a specific
I am using jquery to determine the width of the control:- $(#div1).width(); There is
Here's a dead-simple webpage that leaks memory in IE8 using jQuery (I detect memory
I'm conditionally loading a script if the browser is IE8. I'm using jquery's .getScript
I'm using JQuery UI Dialog. In this form, I validate something.I call this 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.