I have a logo at the top of my page, with a simple hover effect changing the logos color. What I would like to do is that every time the user hovers over it, the logo cycles through a few different hover effects. The first hover the logo turns red, the next hover the logo turns orange going through about 5 colors until starting over at red.
My thought was to use jquery to remove the old class and add a new one with a new hover effect, until the end at which point I would add the original class back. My code currently changes the logo to the red on the first hover, and then to the orange on the second hover, but then it gets stuck on orange.
This is my html:
<div class="navbar-header">
<div class="navbar-brand">
<a href="/main" class="logo_1 logo"></a>
</div>
</div>
This is my css:
.logo {
height:44px;
width:161px;
display:block;
}
.logo_1 {background-image: url(../images/logo.png);}
.logo_1:hover {background-image: url(../images/red_logo.png);}
.logo_2 {background-image: url(../images/logo.png);}
.logo_2:hover {background-image: url(../images/orange_logo.png);}
.logo_3 {background-image: url(../images/logo.png);}
.logo_3:hover {background-image: url(../images/green_logo.png);}
.logo_4 {background-image: url(../images/logo.png);}
.logo_4:hover {background-image: url(../images/blue_logo.png);}
.logo_5 {background-image: url(../images/logo.png);}
.logo_5:hover {background-image: url(../images/purple_logo.png);}
This is my jquery:
$('.logo_1').mouseleave(function(){
$(this).addClass('logo_2');
$(this).removeClass('logo_1');
});
$('.logo_2').mouseleave(function(){
$(this).addClass('logo_3');
$(this).removeClass('logo_2');
});
$('.logo_3').mouseleave(function(){
$(this).addClass('logo_4');
$(this).removeClass('logo_3');
});
$('.logo_4').mouseleave(function(){
$(this).addClass('logo_5');
$(this).removeClass('logo_4');
});
$('.logo_5').mouseleave(function(){
$(this).addClass('logo_1');
$(this).removeClass('logo_5');
});