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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:36:31+00:00 2026-05-25T03:36:31+00:00

I am working on a nav menu the markup structure is below, the span

  • 0

I am working on a nav menu the markup structure is below, the span element is added on document.ready: –

<ul id="menu">
        <li class="menu act">Additional Fixture<span class="active"></span></li>
        <li class="menu">list with sub menu
            <ul class="sub-menu">
                <li class="menu">Option one</li>
            <li class="menu">Option two</li>
            <li class="menu">Option three</li>
            <li class="menu">Option four</li>
            <li class="menu">Option five</li>
        </ul>
    </li>
    <li class="menu"">Special Tricast</li>

The span is positioned absolute with a set width and height and contains an arrow image as the background.

I’m using jQuery to animate the span/arrow image when a user clicks on a menu class to move the active span behind the selected menu (li) element as a visual indicator for their selection.

This works fine when active (act) is set at the root li but if positioned anywhere else in the list for example: –

<ul id="menu">
        <li class="menu">Additional Fixture<span class="active"></span></li>
        **<li class="menu act">list with sub menu</li>**
</ul>

The arrow is positioned correctly when the document loads but doesn’t move to the correct selection when clicked by a user. I’ve tried both position and offset for my divLocation variable, and i’m currently using position as offset fails to work even at root.

I’m basically wanting the arrow to be set depending on what page the user has navigated to, so the animation needs to work from whatever starting position regardless of the length or position of the list.

I’ve trawled the forums and tried a few things but i’m stumped to be honest and would greatly appreciate any assistance!!

Below is the jQuery code for animating the span/arrow image: –

var divLocation = $(this).position();

$("span.active").animate({
  'top': divLocation.top + topOffset,
      'left': divLocation.left + leftOffset

}, animationSpeed, "linear", function(){ 

$(selectedElement).addClass("text-light"); 
    $(selectedElement).fadeTo("100", opacityIn);


});
  • 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-25T03:36:32+00:00Added an answer on May 25, 2026 at 3:36 am

    Solution:

    I started playing with the code posted below and realised I was making life difficult for myself by nesting the span containing the arrow image in the li elements themselves. This made the current li element always the 0 position for the span so that if it was at node 3 travelling to node 1 it would have to go to minus numbers.

    The fix was pretty simple really, I moved the span to the the the top of my unordered list and used jQuery .css to set the start position of the image on page load. This way i didn’t have to change the animation code at all or mess with equations.. maths was never my strong point 😉

    Working solution can be seen here (http://www.kryptonite-dove.com/sandbox/menu/fix.html) thanks for the help!

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

Sidebar

Related Questions

I have a horizontal nav menu that I am working on. I have one
In a project I'm working on, we have a nav menu where items are
I'm working on a navigation like the image below. The whole nav is the
I am currently using wp_nav_menu to generate my nav menu. Although everything is working
I have the following page I'm working on: http://jeunespoir.org/demo/ . The top nav menu
I'm working on a site currently which has a simple css nav menu with
The menu structure I have is given below. The necessary requirements are: Each li
My wordpress*(a custom template)* nav is all working on all of the pages but
I have a css horizontal menu with a menu / submenu display working on
I'm working on a WordPress site that uses a dynamically generated menu system which

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.