I am trying to use the .hover function to change the background color of a menu. Each menu item has a different background color, so I want it to return to its original color when the user hovers off. In other words, I want the script to read the current background color and then reset it after the hover.
However, the code below is not working as expected. I'm struggling to figure out how to pass the variable for background-color in the second part of the hover script:
$('#dmenu ul li a').hover(
function () {
var bgOn = $(this).css('background-color');
$(this).css('background-color', '#efefef');
},
function () {
$(this).css('background-color', (bgOn);
}
);
I admit that I'm not very experienced with JQuery, so I'm sure it's just a simple fix. Any help would be greatly appreciated. Thanks!