Ankor滚动缓和

时间:2014-05-23 23:28:03

标签: jquery easing jquery-easing

我使用libary easing滚动到ankor,但我的代码无法工作,如果我点击第二个ankor它再次跳到顶部然后根本不工作。 这是我的主页我正在努力:

http://www.o-hoerr.de

这是我使用的jq:

$(function() {

//catch all the clicks on tags
$("a").click(function() {

//check if it has a #
if(this.hash){
//get rid of the # sign
var hash = this.hash.substr(1);

//get the position of the <a name>
var $toElement = $("a[name="+hash+"]");
var toPosition = $toElement.position().top;

//scroll/animate

$("body,html").animate({
  scrollTop : toPosition
},2000,"easeOutExpo");


return false;  
}



});

  if(location.hash) {
  var hash = location.hash;
  window.scroll(0,0);
  $("a[href="+hash+"]").click();

}


});
如果有人可以帮助我,那会很好 真诚的奥利弗

1 个答案:

答案 0 :(得分:0)

尝试在Name-tag

中添加一些内容(文本)或非破坏空格

e.g:

<a name="Simulight">SSS</a>
<a name="Simulight">&nbsp</a>
相关问题