用于dokuwiki页面上的clickNshow的jQuery脚本(jQuery script for clickNshow on a dokuwiki page)

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

dokuwiki提示和技巧页面显示了一个很好的小jquery脚本,可以促进这种点击和显示行为 。 我对它进行了修改,使其仅适用于'h2',而不适用于其他标题。

现在我唯一想要的是默认隐藏2级部分。 我试图在div.level2{display:none;}添加一个CSS div.level2{display:none;} ,但这并没有真正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?

最满意答案

jQuery("h2").click(function(){ jQuery("div.level2").toggle(); });

尝试使用此代码。

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

该功能切换你的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

. . . . .

更多推荐