だから私は自分のページでjQueryスクロールがうまく機能するようになりました。でも、ひとつだけ変えたい。URLにアンカーテキストを表示したくありません。すなわち。#products または #contactinfo
HTML コード:
<div>
<a href="#products">Products</a>
<a href="#contactinfo">Contact info</a>
</div>
<div id="products"></div>
<div id="contactinfo"></div>
jQuery コード:
$(document).ready(function(){
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});
});