I want to change the color of the li as red on mouse over. And keep the same color in click event also. I have the following list,
// CSS: Create the highlight accessible with two classnames.
.highlight, .highlight_stay{
color:red;
}
Jquery
$(function(){
$('li').hover(function(){
$(this).addClass('highlight');
}, function(){
$(this).removeClass('highlight');
});
$('li').click(function(){
$(this).addClass('highlight_stay');
});
});
To remove the click color when a different li
is clicked change the last function to this:
$('li').click(function(){
$(li).removeClass('highlight_stay');
$(this).addClass('highlight_stay');
});