我正在使用我在 JS fiddle 上找到的这个脚本:http://jsfiddle.net/Q4PUw/2/
当我点击切换链接时,它会切换框并显示它,但是,它会跳回页面顶部,然后我必须再次向下滚动才能查看已切换的内容。
我该怎么做才能使页面保持在该内容上,以便用户不必再次向下滚动即可查看内容?
这是我的代码:
<style type="text/css">p.content-one {display:none;}</style>
<script type="text/javascript">//<![CDATA[
$(window).load(function(){
$('.expand-one').click(function(){
$('.content-one').slideToggle('slow');
});
});//]]>
</script>
<div class="sitesection">
<p class="expand-one"><a href="#">Toggle Test Here</a></p>
<p class="content-one">
The content goes here
</p>
</div>
最佳答案
remove href="#" in <a> tag
或
If you dont want, remove a tag because you are using expand-one class in p tag
关于jquery 切换...跳转到页面顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25525784/