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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:21:11+00:00 2026-06-13T06:21:11+00:00

On page load I want to highlight a menu item and unhighlight it again

  • 0

On page load I want to highlight a menu item and unhighlight it again after a second. I want to accomplish sort of a Knight Rider effect but only in one direction. From left to right and it should stop when it has traversed all the menu items. This way I want to put more attention on my menu bar.

My HTML:

<div id="header">
    <ul class="menu">
        <li class="menu-item"><a class="menu-item-link">Stage1</a></li>
        <li class="menu-item"><a class="menu-item-link">Stage2</a></li> 
    </ul>
</div>

My CSS:

.highlight { color: #FFFFFF; }

$(document).ready(function () {
$(".menu-item a").each(function () {
        $(this).addClass('highlight').delay(1000).removeClass('highlight');
    });
});

I have tried the below suggestions but it didn’t work.

  • 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-13T06:21:12+00:00Added an answer on June 13, 2026 at 6:21 am

    You might want to try a recursive / callback pattern to add the next element’s class as soon as the previous one gets removed.

    var runner = function (el) {
    
        var next = el.addClass('highlight').next('.menu-item a');
    
        setTimeout(function () {
            el.removeClass('highlight');
            next && runner(next);
        }, 1000)        
    };
    
    runner($('.menu-item a:first'));
    

    Untested code though. I’ll see if I can whip up a jsFiddle in a while.

    EDIT

    Here you go.

    EDIT 2

    … and that’s the reason why you also post the relevant HTML code.

    So, considering HTML like:

    <div id="header">
        <ul class="menu">
            <li class="menu-item"><a class="menu-item-link">Stage1</a></li>
            <li class="menu-item"><a class="menu-item-link">Stage2</a></li> 
        </ul>
    </div>
    

    use this instead:

    var items = $('.menu-item a'),
        runner = function (el) {
    
            var next = items.eq(items.index(el) + 1).addClass('highlight');
    
            setTimeout(function () {
                el.removeClass('highlight');
                !!next.length && runner(next);
            }, 1000);
        };
    
    runner(items.first());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html <label>Hello\r\nUsername</label> <textarea></textarea> After page load i want to set
I want to load an external javascript after page is loaded. Actually the javascript
I want on page load for the class of a li tag to be
I want to get exception of page load, but still have not results on
Hi I want to set opacity for a form in page load. I try
I want to fake a simple animation on page load by sequentially revealing several
I want to load up a random image while a page it is loading
I want to load google.com into a page in my site. I tried using
I want to display images on a .net page which I load from database
I have a product listing page and want to load up a detail view

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.