如何在wordpress的页面模板上使用页面滚动到id插件?
我有一个主页,它是使用wordpress中的多个小模板页面创建的。我在上面设置了菜单。现在我想使用菜单继续特定的部分/模板。比如,如果我按下联系人菜单按钮,那么它应该平稳地向下进入主页,在主页上调用了联系人模板。我正在使用wordpress的“页面滚动到id”插件,但它不工作。我还看到,当页面由Dashboard页面创建时,这个插件可以工作。请帮助我,如何使用此插件导航到我的模板页面/部分。如果有其他插件,请告诉我。我也会尝试使用它如何在wordpress的页面模板上使用页面滚动到id插件?,wordpress,Wordpress,我有一个主页,它是使用wordpress中的多个小模板页面创建的。我在上面设置了菜单。现在我想使用菜单继续特定的部分/模板。比如,如果我按下联系人菜单按钮,那么它应该平稳地向下进入主页,在主页上调用了联系人模板。我正在使用wordpress的“页面滚动到id”插件,但它不工作。我还看到,当页面由Dashboard页面创建时,这个插件可以工作。请帮助我,如何使用此插件导航到我的模板页面/部分。如果有其他插件,请告诉我。我也会尝试使用它 感谢要在链接上创建平滑滚动,请单击以下步骤: 步骤1:在菜单h
感谢要在链接上创建平滑滚动,请单击以下步骤: 步骤1:在菜单href中添加节ID,包括来自管理节
外观>>菜单的#节1
步骤2:创建id名为section1的节或div
<div id="section1"></div>
我希望它能帮助您。它正在工作,但为什么我单击菜单时需要1-2秒?根据需要减少动画毫秒参数。
$(document).ready(function(){
// Add smooth scrolling to all links
$("a").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 800, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
} // End if
});
});