Javascript sectionName为false时Scrollify Move不工作
我正在使用Scrollify插件。我想在单击按钮时移动到某个分区。但是当我将Javascript sectionName为false时Scrollify Move不工作,javascript,jquery,jquery-scrollify,Javascript,Jquery,Jquery Scrollify,我正在使用Scrollify插件。我想在单击按钮时移动到某个分区。但是当我将sectionName设置为false时,它似乎不起作用。当sectionName未设置为false时,它可以正常工作,但我不想在地址栏上看到#,因为当我刷新/重新加载页面(例如第3节)并滚动时,它会向右滚动到下一节(从第1节到第4节)当sectionName为false时,是否有方法将移动到特定节 以下是我到目前为止所做的: JS $('.goNotify').click(function (e) { e.pr
sectionName
设置为false
时,它似乎不起作用。当sectionName
未设置为false
时,它可以正常工作,但我不想在地址栏上看到#,因为当我刷新/重新加载页面(例如第3节)并滚动时,它会向右滚动到下一节(从第1节到第4节)当
sectionName
为false
时,是否有方法将移动到特定节
以下是我到目前为止所做的:
JS
$('.goNotify').click(function (e) {
e.preventDefault();
$.scrollify.move($(this).attr("href"));
});
HTML
<a href="#notify" class="goNotify">
<button id="btnDrive" class="btnNotif" type="button" name="btnDrive" title="Get Notified When Available">Get Notified When Available</button>
</a>
<section id="notify" class="panel" data-section-name="notify">
<!-- content -->
</section>
谢谢!:) 您需要将要移动到的节的索引传递到移动方法。您需要将要移动到的节的索引传递到移动方法。当然,因此我遇到了相同的问题,并通过以下代码绕过它:
$("a.scrollify").on("click",function() {
$.scrollify.move( getScrollifySectionIndex( $(this).attr("href") ) );
});
«getScrollifySectionIndex»方法解析href并返回面板索引:
function getScrollifySectionIndex(anchor){
var idpanel = false;
jQuery('section.panel').each(function(i){
if( jQuery(this).data('section-name') == anchor.toString().replace(/#/g,"") ){
//console.log( jQuery(this).data('section-name') , i , anchor.toString().replace(/#/g,"") );
idpanel = i;
}
});
return idpanel;
};
它工作得很好:)当然,所以我遇到了同样的问题,并通过以下代码绕过它:
$("a.scrollify").on("click",function() {
$.scrollify.move( getScrollifySectionIndex( $(this).attr("href") ) );
});
«getScrollifySectionIndex»方法解析href并返回面板索引:
function getScrollifySectionIndex(anchor){
var idpanel = false;
jQuery('section.panel').each(function(i){
if( jQuery(this).data('section-name') == anchor.toString().replace(/#/g,"") ){
//console.log( jQuery(this).data('section-name') , i , anchor.toString().replace(/#/g,"") );
idpanel = i;
}
});
return idpanel;
};
它工作得很好:)我也遇到了同样的问题。使用相同的场景和类似的代码。不适合我。你能帮我解决这个问题吗?我也有同样的问题。使用相同的场景和类似的代码。不适合我。你能帮我把这个拿出来吗?