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

  • SEARCH
  • Home
  • 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 3403894
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:18:58+00:00 2026-05-18T05:18:58+00:00

I have a script that animates a menu. I don’t want it to if

  • 0

I have a script that animates a menu. I don’t want it to if the menu contains an object with an active class (.active). I can’t figure it out. I have tried several things, but I guess I’m thinking all wrong. Can you help me?

This is the script:

$('#navigation .toplevel, #navigation > ul > li').each(function(idx) {
    $(this).delay( idx * 600 ).fadeIn( 600 );
});

This is the markup:

<div id="navigation">
        <a href="#" class="toplevel">Menu</a>
        <ul class="undermenu"> 
            <li><a href="#">1.0 Menuitem</a>             
                <ul> 
                    <li><a href="#" class="active">1.1 Menuitem</a></li>                     
                    <li><a href="#">1.2 Menuitem</a></li>
                </ul> 
            </li>
            <li><a href="#">2.0 Menuitem</a>             
                <ul> 
                    <li><a href="#">2.1 Menuitem</a></li>                     
                    <li><a href="#">2.2 Menuitem</a></li>
                </ul> </li> 
        </ul> 
</div>

If an UL does contain an active-class, I want it to be shown per default and the LI (the parent) to get an .active-class.

Does it make any sense?

*EDIT:*

The script shall not run if the main UL contains a child (or a childs child) with .active-class. I guess it’s a IF/THEN matter? But I don’t know how to write it.

And…

If “UL LI UL LI A” is active the “UL LI” (parents, parents, parent :D) should be given .active class. How do I do this?

Thank you in advance… 🙂

  • 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-05-18T05:18:59+00:00Added an answer on May 18, 2026 at 5:18 am

    First, to assign the .active class to parent UL elements. You can simply change the selector below to iterate over your UL elements and add the .active class to their parent LI elements:

    $('#navigation > ul > li .active').each(function(){
         $(this).parent().addClass('active');
     });
    

    This will ensure that none of your .active tags are animated:

    $('#navigation .toplevel, #navigation > ul > li').not('.active').each(function(idx) { 
        $(this).delay( idx * 600 ).fadeIn( 600 ); 
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that animates a small DIV popping up on the page.
I have a menu that is toggled when a user selects a link. The
I have a script that fetches several web pages and parses the info. (An
I have a script that lets you put a link at the bottom of
I have a script that runs on some pages. The problem is that I
I have this script that I'd like to in addition save as a xls
how can I make this jquery script close all previously opened children when entering
Howdy. It's me again, and It's jQuery again. I have somthing like that: http://misiur.com/small/
I have the following code that shows 5 posts each being the latest from
I'm using JQuery to create a Horizontal Accordion menu (based on the tutorial at

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.