0
我正在使用pagescroll(Bootstrap),當我使用#scroll或#test作爲鏈接時它工作正常。但是當我使用在/之前使用Pagescroll ID
<a href="/#experiences" class="page-scroll">Experiences</a>
它不會。我想這是因爲/的,但我需要它,所以菜單返回,而不是僅僅增加一個#experiences到annother鏈接像
www.test.de/othersite#experiences
這是我的jQuery。這是可以在jQ中解決嗎?
$('a.page-scroll').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: ($($anchor.attr('href')).offset().top - 50)
}, 1250, 'easeInOutExpo');
event.preventDefault();
});
dang it。我之前嘗試過使用 var str = $(this); var $ res = str.replace(「/」,「」); 但它似乎沒有工作。你的替換工作得很好。謝謝! – Isengo