我的网站http://www.iancockram.com是一个单页作品集。我要解决的问题是我希望突出显示处于活动状态的菜单按钮。
我试图配置它,但永远无法让它工作..
**JQUERY**
//scrollTo
$(document).ready(function(){
$('nav ul li a').click(function(){
var el = $(this).attr('href');
var elWrapped = $(el);
scrollToDiv(elWrapped, 86);
return false;
});
function scrollToDiv(element,navheight){
var offset = element.offset();
var offsetTop = offset.top;
var totalScroll = offsetTop-navheight;
$('body,html').animate({
scrollTop: totalScroll
}, 500);
}
});//scrollTo end
**HTML**
<nav>
<ul id="top-menu">
<div id="logo"><img src="furniture/logo.png" width="242" height="90" alt="iancockram.com" title="iancockram.com"></div>
<li class="button"> <span class="menutext"><a href="#contact">Contact</a></span></li>
<li class="button"> <span class="menutext"><a href="#extra">Extra</a></span></li>
<li class="button"> <span class="menutext"><a href="#portfolio">Portfolio</a></span></li>
<li class="button"> <span class="menutext"><a href="#about">About</a></span></li>
</ul>
}