i want highlight the menu point if the div is scrolled // or clicked.
http://jsfiddle.net/WeboGraph/vu6hN/2/ (thats an example what i want)
my code: (JS)
$(document).ready(function(){
$('nav a').on('click', function(event) {
$(this).parent().find('a').removeClass('active_underlined');
$(this).addClass('active_underlined');
});
$(window).on('scroll', function() {
$('.target').each(function() {
if($(window).scrollTop() >= $(this).position().top) {
var id = $(this).attr('id');
$('nav a').removeClass('active_underlined');
$('nav a[href=#'+ id +']').addClass('active_underlined');
}
});
});
});
my (html nav)
<nav>
<div id="cssmenu">
<ul id="horizontalmenu" class="underlinemenu">
<li><a data-scroll href="#fdesigns" class="active_underlined">FDesigns</a> </li>
<li><a data-scroll href="#skills">skills</a> </li>
<li><a data-scroll href="#workflow">WORKFLOW</a> </li>
<li><a data-scroll href="#portfolio">Portfolio</a> </li>
<li><a data-scroll href="#about">About</a> </li>
<li><a data-scroll href="#kontakt">Kontakt</a> </li>
</ul>
</div>
</nav>
my (css)
.active_underlined a {
color: #fff;
border-bottom: 2px solid #ebebeb;
}
a.active_underlined {
color: #fff;
border-bottom: 2px solid #ebebeb;
}
here a link to the project: http://www.f-designs.de/test_onesite