Opened 12 years ago
Closed 12 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 follow-up: 2 Changed 12 years ago by
Owner: | set to tsukasa1989 |
---|---|
Status: | new → pending |
comment:2 Changed 12 years ago by
Status: | pending → new |
---|
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 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
http://jsfiddle.net/FrKyN/208/
Read the selector from right to left. You're selecting labels below #container and there are none. Followups to http://forum.jquery.com.
Note: See
TracTickets for help on using
tickets.
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.