不幸的是我在localhost上使用Joomla而无法提供网页链接。
我有一个网页,可以使用smoothscrolling来锚定链接。
菜单固定在左侧,并使用简单的
<a href="#wrapper">top</a>
<a href="#section1">section1</a>
<a href="#section2">section2</a>
<a href="#section3">section3</a>
当我将任何jQuery手风琴扩展激活到任何部分时,我的问题就出现了。 (我已经下载并尝试了所有这些)
如果我将手风琴放在第1部分,所有页面跳转除了第2节和第2节之外3不行。
如果我将手风琴放在第2部分,第3部分的页面锚点不起作用。
我尝试删除返回false;无济于事:
jQuery(document).ready( function () {
//Set default open/close settings
jQuery('.xac-container').hide(); //Hide/close all containers
jQuery('.xac-trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
//On Click
jQuery('.xac-trigger').click(function(){
if( jQuery(this).next().is(':hidden') ) { //If immediate next container is closed...
jQuery('.xac-trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
jQuery(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
}
else{
jQuery('.xac-trigger').removeClass('active');
jQuery(this).next().slideUp();
}
// return false; //Prevent the browser jump to the link anchor
});
});
我看了一些CSS教程来制作手风琴,但它为每个被点击的手风琴项创建了pagejump,并且不必要地增加了浏览器历史记录。
我希望我足够清楚。这似乎是一个常见的问题,但我冗长的搜索没有结果。
答案 0 :(得分:0)
Lodder评论的正确答案。
我加载了多个jQuery库。
警惕复制粘贴随机代码。