Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Background-color of menue with jquery

Tags:

java

jquery

css

php

I am trying to build a photo gallery with Zenphoto. They use php and one can add a custom menue like this:

    <div id="navmenu">
    <?php printCustomMenu('main_menue'); ?>
    </div>

I changed the appearance of the whole thing in the sylesheet, which looks like this:

#navmenu {
        width: 1000px;
        height: 42px;
        margin: 0px auto 30px auto;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        text-align: left;
        font-size: 21px;
        background-color: #000000
        }

#navmenu li {
        display: inline; 
        }

#navmenu a {
        color: #eee;
        display: inline;
        line-height: 2em;
        padding: 0.375em 0.5em;
        text-decoration: none;
            }

#navmenu a:hover {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 21px;
        color: #000000;
        background-color: #ffff33;
        padding: 0.375em 0.5em;
            }

Now I want to change the background-color of the individual menu items, so that every menu item has its own color. Random or not I don't care. I created a js file that is wired correctly.

I have tried several bits of code I found, but nothing works. Now I tried to do this to see if I can change the color at all:

 $(document).ready(function() {

 $("navmenu").hover(function(){
  $(this).css('background-color', '#eeeeee')
 });
});

Does not work. I am new to all this programming and I would greatly appreciate any help. It would be super nice if you could answer for dummies, so that I can understand.

like image 281
Anette Avatar asked Oct 06 '22 14:10

Anette


1 Answers

Use:

$("#navmenu").hover(function(){

You missed the ID # selector.

like image 107
Tom Walters Avatar answered Oct 12 '22 00:10

Tom Walters