0
我在一个“div”中显示了4个不同的表格,该表格显示链接列表,即显示的表格根据列表中的哪个链接被点击而改变。禁用页面滚动为“href”
当用户点击某个链接时,页面会自动向下滚动到“div”的顶部。我想禁用此页面移动,有没有办法做到这一点?
基本上,我希望用户能够选择他们想要查看的表格,但不希望页面自动滚动到“div”的顶部。
<ul style="list-style-type: none; margin: 0; padding: 0; overflow: hidden;">
<li style="list-style-type: none; float: left;"><a style="color: white; font-size: 100%;" href="#MB"><strong>ONE</strong></a></li>
<li style="list-style-type: none; float: left;"><a style="color: white; font-size: 100%;" href="#DS"><strong>TWO</strong></a></li>
<li style="list-style-type: none; float: left;"><a style="color: white; font-size: 100%;" href="#AF"><strong>THREE</strong></a></li>
<li style="list-style-type: none; float: left;"><a style="color: white; font-size: 100%;" href="#DT" ><strong>FOUR</strong></a></li>
<div style="width: 100%; float: right; overflow: hidden;">
<div style="white-space: nowrap; width: 400%;">
<div id="MB" style="vertical-align:top;display: inline-block; width: 25%;">[table id=28/]</div>
<div id="DS" style="vertical-align:top;display: inline-block; width: 25%;">[table id=29/]</div>
<div id="AF" style="vertical-align:top;display: inline-block; width: 25%;">[table id=35/]</div>
<div id="DT" style="vertical-align:top;display: inline-block; width: 25%;">[table id=36/]</div>
</div>
</div>
你能提供一个关于我可以在哪里获得相关信息的建议吗? – Morts81
https://stackoverflow.com/questions/3659072/how-to-disable-anchor-jump-when-loading-a-page –
谢谢凯瑟琳。我对JavaScript没有任何经验,我可以将代码添加到与我的HTML代码相同的代码片段文件中吗?有什么特别的使用JavaScript的? – Morts81