我有這個代碼,它運作良好。平滑滾動如何使用摘錄?
$('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