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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:53:44+00:00 2026-05-14T02:53:44+00:00

I have the following jQuery function: $(function(){ if ($(.menu li).hasClass(active)) { $(.active).css(margin-top, 6px); }

  • 0

I have the following jQuery function:

$(function(){
            if ($(".menu li").hasClass("active")) {
                    $(".active").css("margin-top", "6px");
              }
        });

This is applied to a CSS/jQuery menu, which expands and contracts when each menu item is hovered over. The onClick event adds a margin-top of 6px to give the impressions of a button depress.

I’m then using PHP to detect which page the user is visiting to add an .active class to the relevant menu item.

The question, the .active class should remain in place until the user hovers over a different menu item. At which point the .active class should be removed from this element – As the .active class is reused on the .hover events.

Here is the basic HTML Markup:

<ul id="menu">
<li>
<div class="inner">
<div class="button"><img src="images/insightbutton.png" /></div>
<div class="description">&nbsp;</div>
</div>
</li>
<li>
<div class="inner">
<div class="button"><img src="images/insightbutton.png" /></div>
<div class="description">&nbsp;</div>
</div>
</li>
</ul>

How can I keep the .active class applied to the active menu item, but remove it when .inner is hovered over?

  • 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-14T02:53:44+00:00Added an answer on May 14, 2026 at 2:53 am

    You could do this:

    $(".menu li.active").addclass("onPage");
    $(".menu li").hover(function() {
      $(".menu li.active").removeClass("active");
      $(this).addClass("active");
    }, function() {
      $(this).removeClass("active");
      $(".menu li.onPage").addClass("active");
    });
    

    This code does the following:

    • Assigns a placeholder class to the original active (assigned by your PHP).
    • On hover, removes the active class from all <li> siblings and sets the hovered to one to active.
    • On leaving hover, it removes active from itself and selects the placeholder and restores active to the original (the page they’re on).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I am a huge fan of wordpress MU. There is… May 16, 2026 at 3:47 pm
  • Editorial Team
    Editorial Team added an answer $wrap = array($data, $options); is equivalent to $wrap = array(0=>$data,… May 16, 2026 at 3:47 pm
  • Editorial Team
    Editorial Team added an answer This paper could be a good starting point for you,… May 16, 2026 at 3:47 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the following jQuery code: $(ul.menu li a).click(function() { $(ul.menu li a).removeClass(currentMenu); $(this).addClass(currentMenu);
I have the following jquery which animates on hover: $('#footerNetwork').hover(function(){ $('#popupNetwork').animate({top:'-62px'},{queue:true,duration:500}); }, function(){ $('#popupNetwork').animate({top:'30px'},{queue:true,duration:500});
I have the following jQuery code $(#dropdown).hover(function() { $(this).stop(true,true).fadeTo('fast',1); $(#options).stop(true,true).slideDown(); }, function() { $(this).delay(1000).stop(true,true).fadeTo('fast',0.1);
I have the following jQuery code which all works fine: $(#sidebar .m3, #sidebar .m5).toggle(function()
I have the following code in Javascript: jQuery(document).ready(function(){ var actions = new Object(); var
I have the following ul setup: <div id=sidebar> <ul id=themenu class=sf-menu sf-vertical> <li> <a
I have the following scenario. I have a index.php page with the following JQuery
I have the following jquery I'd like to convert to prototype. I am having
I have the following HTML code based on a tab menu format, i.e: <div
I have the following JQuery, I want to display the default divarea1 visible when

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.