dokuwiki 页面上 clickNshow 的 jQuery 脚本

发布于 2024-09-02 00:26:43 字数 415 浏览 4 评论 0原文

我正在为我们公司制作一个 dokuwiki,但由于文档往往会变得非常大,所以我想折叠各个部分并仅显示标题。单击标题后应显示这些部分。

dokuwiki 提示和技巧页面显示了一个漂亮的小 jquery 脚本,该脚本有助于点击并显示行为。我对其进行了修改,使其仅适用于“h2”,而不适用于其他标头。

现在我唯一想要的是 2 级部分默认隐藏。我尝试将 CSS div.level2{display:none;} 添加到主页,但这并没有真正起作用。它确实隐藏了这些部分,但当单击标题时它们不再出现。

当使用 javascript 代码加载页面时,有没有办法隐藏 h2 标题下方的所有部分?

I am making a dokuwiki for our company, but because the documents tend to get very large, I want to collapse the sections and only show the headers. The sections should appear when the header has been clicked.

The dokuwiki tips and tricks page shows a nice little jquery script that facilitates this click and show behaviour. I modified it so that it only applies to 'h2' and none of the other headers.

Now the only thing I want is that the level 2 sections are by default hidden. I tried to add a CSS div.level2{display:none;} to the main page, but this does not really do the trick. It does hide the sections, but they do not appear anymore when the header is being clicked.

Is there a way to hide all sections below the h2 headers when the page loads using the javascript code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北城挽邺 2024-09-09 00:26:43
jQuery("h2").click(function(){

jQuery("div.level2").toggle();

});

尝试使用此代码。

第一行选择 h2 并告诉何时单击它应该调用该函数,

该函数切换你的 level 2 div

。 。 。 。 。

jQuery("h2").click(function(){

jQuery("div.level2").toggle();

});

Try using this code.

The first line selects h2 and tell when its clicked it should call the function

the function toggles ur level 2 div

. . . . .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文