how to find an element based on two selectors?

i have a doom tree like this:

ul #navigation
    li .active
    ul
        li.active_li
        li
        li
    /ul
    li
    ul
        li.active_li
        li
        li
    /ul
/ul

i would like to find the li with a class of active_li inside the ul belonging to the li that has a class of active. :)

as we can see there are 2 li with a class of active_li. i want only the first one

something like: $('#navigation').find('li.active').find('li.active)li').doSomething();

this selector doesn't seem to work

any ideas?

Answers


Try this selector:

$('#navigation li.active ul li.active_li')
                         ^^
                          \_ You can get rid of this, as <li> elements
                             exist only within <ul> elements.

You can use

$('#navigation li.active li.active_li').each(function(){

});

and flag the function off after running the first one.

Or if you just want the first one selected:

 $('#navigation li.active li.active_li').first();

Need Your Help

iOS Server Side Validation - receipt types

ios in-app-purchase server-side-validation

I'm getting 2 kinds of receipt formats from Apple when i try to verify purchases on the server.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.