Bug Tracker

Modify

Ticket #5593 (closed bug: worksforme)

Opened 3 years ago

Last modified 3 years ago

DOM parent()

Reported by: piotrpolak Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

The result of the following code

#1 $( $("ul.subsubmenu li a.active").parent() ).parent().children("li").children("a");

differs from

#2 $("ul.subsubmenu li a.active").parent().children("a");

In the case #2 it returns the same "a" element having class "active". The desired behavior (case #1) is to select all "a" elements from the list having an "a" element having class ".active".

Here is an example HTML code: <ul>

<li><a href="xx.html">xxx</a></li> <li><a href="zz.html">zz</a>

<ul class="subsubmenu">

<li><a href="cc.html">cc</a></li> <li><a href="ccx.html">ccx</a></li>

</ul>

</li> <li><a href="qqq.html">qqq</a></li> <li><a href="eventy.html" class="active">fff</a>

<ul class="subsubmenu">

<li><a href="ll.html" class="active">ll/a></li> <li><a href="bb.html">bb</a></li>

</ul>

</li>

</ul>

Change History

comment:1 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to worksforme
  • Component changed from unfilled to core

That's because you're not walking far enough up the tree - case #1 is correct for this particular use case (although you don't need to wrap the jQuery set a second time).

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.