Bug Tracker

Opened 8 years ago

Closed 8 years ago

#11031 closed feature (invalid)

.children() multiple hierarchy levels

Reported by: tsukasa1989 Owned by: tsukasa1989
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

Description

Currently working on a project and since I do know the exact structure and I want a good performance I am using the following code (this is faster then .find()):

$("#moduleConatainer").children("table").children("tbody").children("tr");

The code functions, but it would be better if something like this is possible, which currently returns 0 elements:

$("#moduleConatainer").children("table tbody tr")

Change History (3)

comment:1 Changed 8 years ago by dmethvin

Owner: set to tsukasa1989
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 in reply to:  1 Changed 8 years ago by tsukasa1989

Status: pendingnew

I have a fiddle here: http://jsfiddle.net/FrKyN/163/

Running this code:

console.log("children('div').children('label') length: " + $("#container").children("div").children("label").length);

console.log("children('div label') length: " + $("#container").children("div label").length);

On this HTML:

<div id="container">
    <div>
        <label></label>
    </div>
</div>

Result:

children('div').children('label') length: 1
children('div label') length: 0

comment:3 Changed 8 years ago by dmethvin

Resolution: invalid
Status: newclosed

http://jsfiddle.net/FrKyN/208/

Read the selector from right to left. You're selecting inputs below #container and there are none. Followups to http://forum.jquery.com.

Version 0, edited 8 years ago by dmethvin (next)
Note: See TracTickets for help on using tickets.