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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:18:10+00:00 2026-05-17T22:18:10+00:00

The menu structure I have is given below. The necessary requirements are: Each li

  • 0

The menu structure I have is given below. The necessary requirements are:

Each li must be a toggle where it can be selected and deselected for items 1-4. Multiple li’s can be selected between the range of 1-4. So a user could select Item 1 & Item 3 and their background would both be highlighted. Upon hovering over any of the Items and the “All” li selection items, there should be a mouseOver/mouseOut background change. If an Item is selected, then there should be no hover state of mouseOver/mouseOut.

Finally if the “All” li is selected, the rest of the Items (if selected) should all reset their toggle states and become deselected. Then if another Item is selected after that, the “All” selection should reset itself as well.

Here’s what I’ve got so far and I have the hover state working fine for all the components. I don’t know how to write the unbinding operation for the reset of all the Items 1-4 when “All” is selected so the ‘state’ of the Items 1-4 resets, and then also the reset for the “All” button if it is selected and then an Item 1-4 is chosen afterwards.

Sorry to be wordy but I want to try and explain it as best as possible so there is no confusion. 🙂

//css
.liselected{
background-color:#256ca0;
}

.lihoveron{
background-color:#eceef5;
}




$(document).ready(function() {

var startToggle = function(){
$('li[id|=nav]').toggle(
    function() {
        $(this).addClass('liselected').children().css('color','#ffffff');
        $(this).removeClass('lihoveron');
    },
    function() {
        $(this).removeClass('liselected').children().css('color','#5D788B');
    }).mouseover(function() {
        $(this).css('cursor','pointer');
    }).hover(function() {
        if ( $(this).hasClass('liselected') ){
        }
        else{
            $(this).addClass('lihoveron');
        }
    }, function() {
    $(this).removeClass('lihoveron');
});
};

startToggle();

});



<ul>
<li id="nav-all">
    <a class="item" href="">
        All Items
    </a>
</li>
<li id="nav-item1">
    <a class="item" href="">
        Item 1
    </a>
</li>
<li id="nav-item2">
    <a class="item" href="">
        Item 2
    </a>
</li>
<li id="nav-item3">
    <a class="item" href="">
        Item 3
    </a>
</li>
<li id="nav-item4">
    <a class="item" href="">
        Item 4
    </a>
</li>
<li id="nav-item5">
    <a class="item" href="">
        Item 5
    </a>
</li>

  • 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-17T22:18:10+00:00Added an answer on May 17, 2026 at 10:18 pm

    I would do it something like this:

    1. you have an array with indices of selected elements i.e. [2,23,5,1].
    2. when a new element is selected a function need to check if the array has max allowed elements. i.e. 4 if so, remove the first element and add the new clicked.
    3. then you have to deselect all elements and make selection of the elements in the array.

    in the first time you have empty array: []
    on first selected element [2]
    on the second [2,23]
    and so on.

    when elements are 4 [2,23,5,1] and you clicked for example on 7-th element then you remove 2 from the array and add 7 in the end.
    it will look like: [23,5,1,7]

    then you make:

    $('li.elementsClass').removeClass('liselected')
    

    and then loop the array and add class liselected of each element in the array.

    HTH

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

Sidebar

Related Questions

I ahve a menu structure that uses UL and LI elements to drop down
I can create a menu item in the Windows Explorer context menu by adding
I have a menu running off of a sitemap which one of the SiteMapNode
I have a asp:menu object which I set up to use a SiteMapDataSource but
I have a menu control inside of an updatepanel. When I hover over a
I have a menu with an animation going on, but I want to disable
I've got menu items that look like this <ul> <li>Item1<span class=context-trigger></span></li> <li>Item2<span class=context-trigger></span></li> <li>Item3<span
I have something like : var myMenu= [ { 'My English Title':function(menuItem,menu) { ...
I would like to parse the menu structure for Gnome Panels (the standard Gnome
I've got a menu in Python. That part was easy. I'm using raw_input() to

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.