你好,我有一个问题。我需要在单击时从锚点滚动到元素,但是我遇到了错误:
SyntaxError: 属性列表后缺少 }
scrollTop: $( $(this).attr('href') )element.offset().top
/* jQuery scroll to element on click */
$(document).ready(function(){
$('nav#site-navigation ul li').click(function(){
$('html, body').animate({
scrollTop: $( $(this).attr('href') ).offset().top
}, 1000);
return false;
});
});
在WordPress导航菜单中,anchor指的是锚点。
scrollTop: $($(this).attr('href'))element.offset()。top
- Roko C. Buljan