I have several buttons on a page whose color is changed through jQuery, illustrating which one is active. I would like to add a color change ONLY when hovering, after which it reverts to the original color (which is dictated by jQuery) when it remains.
At first I used css: .showlink li:hover {color:#aaa;} , which works accordingly, except when the pages switch and jQuery changes colors, it is superior to CSS.
Then I decided to use simple jQuery, which says when something freezes, change its color. this does not fully work because it is constantly changing color. To reduce this, I added a little to the function, which returns it to a different color.
Is there a way to return the original color before it was changed when you hover over it?
// Changes color on hover $(function() { $('.showlink').hover(function(){ $(this).css('color', '#aaa'); }, function(){ $(this).css('color', '#f3f3f3'); }); }); //Changes color depending on which page is active, fades that page in $(function(){ $('#show_one').css('color', '#ffcb06'); $('#two, #three').hide(); }); $('.showlink').click(function(){ $('.showlink').css('color', '#f3f3f3'); $(this).css('color', '#ffcb06'); var toShow = this.id.substr(5); $('div.page:visible').fadeOut(600, function(){ $('#' + toShow).fadeIn(600); }); });
source share