我有菜单这个非常简单的页面,包含三个<ul>
S和内容DIV:http://jsfiddle.net/vvqPN/内容加载到DIV
的jQuery:
$(document).ready(function() {
$('.subcontent:gt(0)').hide();
$('#menu').on('click', 'li:not(.current) a', function() {
$('.current').not($(this).closest('li').addClass('current')).removeClass('current');
// fade out all open subcontents
$('.subcontent:visible').hide(600);
// fade in new selected subcontent
$('.subcontent[id=' + $(this).attr('data-id') + ']').show(600);
});
});
在页面,当你点击第一个<ul>
第一个内容加载到内容div中,然后当您单击第二个<ul>
时,第二个内容加载到内容div中,第三个内容加载到第二个内容中。 我正在试图解决的问题是,当你在页面向下滚动,并尝试点击任何<ul>
S中的页面自动返回到页面顶部。
你的锚链接正在寻找定义为''#不存在的,因此,将其发送给你的文件顶部的锚。你可以指定''作为你锚链接的'href',或者你可以做下面建议的@kunalbhat。我建议@ kunalbhat的答案,因为它是不显眼的。 – crush