gpt4 book ai didi

css - div 的长页面 : Use Effect. 切换以在底部展开一个 div:页面滚动回到顶部

转载 作者:行者123 更新时间:2023-11-27 22:37:01 24 4
gpt4 key购买 nike

我有一页看起来像这样的东西(是的,我已经包括了 scriptaculous javascripts,因为切换确实有效):

<html>

<div id="container">
<div id="thing1" class="thing" >
<p>Some visible stuff 1</p><a href="#" onclick="Effect.toggle('extra1');">More1</a>
<div id="extra1" style="display:none;">
<p>Some extra and initially invisible stuff</p>
</div>
</div>

<div id="thing2" class="thing">
<p>Some visible stuff 2</p><a href="#" onclick="Effect.toggle('extra2');">More2</a>
<div id="extra2" style="display:none;">
<p>Some extra and initially invisible stuff</p>
</div>
</div>

<!-- 96 more entities of class="thing" -->

<div id="thing99" class="thing">
<p>Some visible stuff 99</p><a href="#" onclick="Effect.toggle('extra99');">More99</a>
<div id="extra99" style="display:none;">
<p>Some extra and initially invisible stuff</p>
</div>
</div>
</div>
</html>

当我单击位于页面底部的 id="thing99"处的“More99”链接时,id="extra99"处的 div 按原样显示,但该页面然后自动显示该页面滚动回到顶部。

当我点击顶部的“More1”链接时,它始终聚焦在顶部。

有什么方法可以防止页面滚动回顶部和/或将其重新聚焦到我刚刚单击的位置?我不想向下滚动并找出我刚刚显示的那一个。

最佳答案

Effect.toggle(); 调用后尝试 return false;

<a href="#" onclick="Effect.toggle('extra99'); return false;">More99</a>

这不是处理此问题的理想方式,但它应该可以解决您眼前的问题。理想情况下,您将从 HTML 中删除所有 Javascript,并取消所有 onclick 属性,从远程 Javascript block 处理所有内容。

关于css - div 的长页面 : Use Effect. 切换以在底部展开一个 div:页面滚动回到顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2073622/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com