Basically I have 3 links, and I used the hover css property to make them white / red when the user enters / leaves the link:
<div id="nav-glob"> <ul> <li class="nav-home"><a href="#content">Home</a></li> <li class="nav-portfolio"><a href="#lavori">Portfolio</a></li> <li class="nav-contact"><a href="#footer">Contact</a></li> </ul> </div> .nav-glob a:hover { color: red; }
Then in jQuery, I used the click()
function to set the css color
property to red:
$('.nav-home > a').click(function(){ $(".nav-home a").css("color", "red"); $(".nav-contact a").css("color", "white"); $(".nav-portfolio a").css("color", "white"); }); $('.nav-portfolio > a').click(function(){ $(".nav-home a").css("color", "white"); $(".nav-contact a").css("color", "white"); $(".nav-portfolio a").css("color", "red"); }); $('.nav-contact > a').click(function(){ $(".nav-home a").css("color", "white"); $(".nav-contact a").css("color", "red"); $(".nav-portfolio a").css("color", "white"); });
The problem is that it works fine the first time: after clicking a single link, the CSS hover
property is ignored! It looks like hover
disabled after clicking. Any help is much appreciated, thanks
source share