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 8513313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:31:51+00:00 2026-06-11T04:31:51+00:00

i have a multilevel menu with anchor-tags in it. My problem is to get

  • 0

i have a multilevel menu with anchor-tags in it.
My problem is to get the jQuery selectors to work properly.

Working code:

$(this)
    .closest('li')
    .siblings('li.open')
    .children('a')
    .children('i')
    .toggleClass('class1')
    .toggleClass('class2');

What it should be:

$(this)
    .closest('li')
    .siblings('li.open > a > i')
    .toggleClass('class1')
    .toggleClass('class2');

But not even this works:

$(this)
    .closest('li')
    .siblings('li.open a i')
    .toggleClass('class1')
    .toggleClass('class2');

What i want to do in text-form:
The onClick event targets an anchor tag. I want the i-Tags in the anchors of the siblings of his parent LI – god that sounds aweful – to toggle two different classes.

HTML

<ul>
    <li>
        <a><i class="class1"></i>Label</a>
        <ul>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
        </ul>
    </li>
    <li class="open">
        <a><i class="class1"></i>Label</a>
        <ul>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
            <li>
                <a><i class="class1"></i>Label</a>
            </li>
        </ul>
    </li>
    <li>
        <a><i class="class1"></i>Label</a>
    </li>
    <li>
        <a><i class="class1"></i>Label</a>
    </li>
    <li>
        <a><i class="class1"></i>Label</a>
    </li>
    <li>
        <a><i class="class1"></i>Label</a>
    </li>
    <li>
        <a><i class="class1"></i>Label</a>
    </li>
</ul>
  • 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-06-11T04:31:53+00:00Added an answer on June 11, 2026 at 4:31 am

    I think the reason it won’t work is because

    ('li.open > a > i') 
    

    is not a sibling of

    $(this).closest('li')
    

    The sibling of the li is another li.

    You could try

    $(this).closest('li').sibling('li.open').find('a > i').toggleClass('blah');
    

    Why can’t you use the first piece of code you posted?

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

Sidebar

Related Questions

Well, I'm working an an ul - li multilevel menu and have problem. Firstly,
Recursive function for copy of multilevel folder is not working. I have a code
I have a custom menu in jQuery that apparently doesn't work with IE 8
I working on the project now which will have massive multilevel menu - to
I have jQuery menu I've been working on based on Stu Nicholls CSS multi-level
I want to design a multilevel menu using jQuery. I have already written some
Hi all I have created a jquery based multilevel nav menu, when onMouse each
I have written a function for a multilevel wordpress menu, but I'd like it
I have a multi-level mega menu on my site (using jquery plugin), however, when
I have a classic UL multilevel menu that works flawlessly in Firefox. The LI

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.