我有这个代码,它运作良好。平滑滚动如何使用摘录?
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
&& location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
但我也有一些元素,我不想为它们应用平滑滚动!我该怎么做 ? 示例 - http://codepen.io/zoom/pen/ggYaXZ 我不aplly希望它< li><a href="#apple">Scroll to Section Apple</a></li>
THKS这是个好主意 – Dmi