I have 4 links that change the position of 4 divs inside a web page. I am using the following jQuery script to change the color of the links when I hover them.
$('a.menua').hover(function(){
$(this).css({'color':'#2EC7C7'});
},
function(){
$(this).css({'color':'white'});
});
how can i modify this script so that when i click a link it keeps the color from hover and not change when i take my mouse off of it?
$('a.menua').click(function(){
//content
});
I would use CSS for all of the styling, like this:
Then only use jQuery just toggle that class using
.toggleClass()like this:Or, if you want only one active at a time:
This makes your code simpler, lighter, and easier to maintain. Also it keeps your styling information where (if at all possible) it belongs, in the CSS.