javascript - resolved: jquery .hover() confusion -


i programming portfolio page , came across strange behaviour off hover states don't understand. have links in navigation bar @ top of page. links defined :hover , everything. want colour of links change when hover mouse on different sections of site links refer to. wrote this:

/* navlink colors */ $('#portfolio').hover(function() {        $('#portlink').css('color','#ff9900');     }, function() {        $('#portlink').css('color','inherit'); }); $('#about').hover(function() {        $('#abolink').css('color','#ff9900');     }, function() {        $('#abolink').css('color','inherit'); }); ... 

at first seems work, when scroll blog , move mouse on navigation css :hover doesn’t seem work anymore. test site:

http://www.henning-marxen.de/test/index.html (don't laugh placeholders^^) know why behaves this? confused. thank in advance.

you need mix of js , css this. in css need apply styles hover state class i'll call current example.

.nav-link:hover, .nav-link.current{   color:#ff9900; } 

then javascript needs add or remove class depending on part of site have scrolled to:

var navlinks = $('.nav-link');  //each time user scrolls, reset links removing class. navlinks.removeclass('current');  //then find link needs highlighting , add class it. //there needs logic here filter correct link. navlinks.filter('[href="#portfolio"]').addclass('current'); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -