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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:25:17+00:00 2026-06-12T03:25:17+00:00

So im new to jquery and I want to make a new navigation menu.

  • 0

So im new to jquery and I want to make a new navigation menu. I want this jquery script to color my list items randomly in a variety of colors of my choosing. Lets just say red, yellow, green, blue and black. Also it should not be possible to have the same color before and after a color is selected.

Further more I want this menu to have a hover function, so that once you hover one of the list items, all the other list items get the color of grey or another css value.

I hope someone could help me build this.

I know I haven’t done much yet.

HTML:

<div id="wrapper">
    <div id="nav">
        <ul id="navigation">
            <li>Home</li>
            <li>About</li>
            <li>Products</li>
            <li>Blog</li>
            <li>Contact</li>
        </ul>
    </div>
</div>

Jquery:

$(document).ready(function() {
    $('#navigation, li').addClass('blue');
});

CSS:

* {
    margin:0px; padding:0px;
}
body {
    background-color:#999;
}

#wrapper {
    width:960px; margin:auto; background-color:#CCC;
}
.blue {
    color:#567;
}

Demo on jsfiddle, link: http://jsfiddle.net/iBertel/vbpXP/11/

  • 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-12T03:25:18+00:00Added an answer on June 12, 2026 at 3:25 am

    Using @massivePenguin’s idea
    Here you go, basically, we create an array, a few css rules with a default hover state of grey on all elements in the list. We end up with this result which has a randomised colour effect.

    This is the key that randomises your array. The magic happens here, to make this a better effect, add 5 or so more colours to the array to add to the “random” effect.

    colours.sort(function() {return 0.5 - Math.random()});
    

    The above code is the key factor in the below script.

    var colours = ['red', 'yellow', 'blue', 'green', 'pink'];
    $(document).ready(function() {
        $('#navigation li').hover(function() {
            colours.sort(function() {return 0.5 - Math.random()});
            $(this).addClass(colours[0]);
        }, function() {           
            $(this).removeClass(colours[0]);      
        });
    });​
    

    http://jsfiddle.net/shannonhochkins/QkWXN/

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

Sidebar

Related Questions

I want to make a similar navigation menu like what m.facebook.com did. but this,
I want to make the new Facebook-like top navigation with CSS and jQuery ,
I am new to jQuery, so I'm having trouble solving this. I want this
i want to know how work facebook new timeline image reposition with jquery? this
I'm new with jquery and want to ask a question, can jquery make something
hi to every one i am new in jquery. i want to make an
i m new to jquery..i want to make an scrollLeft sliding gallery..i have done
I'm new in JQuery, I found this link: jQuery Effects and I want to
I'm new to jQuery and I want to do this simple thing in a
I want to dynamically generate 8 new paragraphs with jQuery: http://jsfiddle.net/johnhoffman/Dfydn/ However, this snippet

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.