gpt4 book ai didi

jquery-ui - 选项卡式导航中的 Accordion

转载 作者:行者123 更新时间:2023-12-02 22:25:02 27 4
gpt4 key购买 nike

我正在创建一个包含多个选项卡的简单页面,每个选项卡内将有 3 个部分,我将使用 Accordion ,因为这是我想要的最佳解决方案。一切都在第一个选项卡上完美运行, Accordion 按其应有的方式运行,并且内容呈现得很好。

当我单击 tab2 时,内容仅呈现为文本,未应用 Accordion 。我已经使用了开发工具,但由于某种原因, Accordion 类没有应用于 tab2 中的 Accordion div。我可能在这里遗漏了一些非常基本的东西,但我将不胜感激任何帮助。

请原谅这里的基本代码布局,但出于演示目的,这就是 html 的样子。

<body>
<h1 class="mainTitle">Page Title</h1>
<div id="tabs">
<ul>
<li><a href="#tabs-1">TAB 1</a></li>
<li><a href="#tabs-2">TAB 2</a></li>
</ul>
<div id="tabs-1"><!-- Start of tabs-1 -->
<div id="accordion">
<h3>Section 1</h3>
<div>
This section is for general information relating to this project.
</div>
<h3>Section 2</h3>
<div>
Section 1 content
</div>
<h3>Section 2</h3>
<div>
Section 2 content
</div>
</div><!-- End of accordion -->
</div><!-- End of tabs-1 -->

<div id="tabs-2"><!-- Start of tabs-2 -->
<div id="accordion">
<h3>Section 1</h3>
<div>
This section is for general information relating to this project.
</div>
<h3>Section 2</h3>
<div>
Section 1 content
</div>
<h3>Section 2</h3>
<div>
Section 2 content
</div>
</div><!-- End of accordion -->
</div><!-- End of tabs-2 -->
</div><!-- End of tabs -->
</body>

最佳答案

你有多个具有相同id的div,即accordion。要么单独命名它们,要么在选择器中使用一个类。例如:

<body>
<h1 class="mainTitle">Page Title</h1>
<div id="tabs">
<ul>
<li><a href="#tabs-1">TAB 1</a></li>
<li><a href="#tabs-2">TAB 2</a></li>
</ul>
<div id="tabs-1">
<div class="accordion">
<h3>Section 1</h3>
<div>
This section is for general information relating to this project.
</div>
<h3>Section 2</h3>
<div>
Section 1 content
</div>
<h3>Section 2</h3>
<div>
Section 2 content
</div>
</div><!-- End of accordion -->
</div><!-- End of tabs-1 -->

<div id="tabs-2"><!-- Start of tabs-2 -->
<div class="accordion">
<h3>Section 1</h3>
<div>
This section is for general information relating to this project.
</div>
<h3>Section 2</h3>
<div>
Section 1 content
</div>
<h3>Section 2</h3>
<div>
Section 2 content
</div>
</div><!-- End of accordion -->
</div><!-- End of tabs-2 -->
</div><!-- End of tabs -->
</body>

然后:

$( ".accordion" ).accordion();

关于jquery-ui - 选项卡式导航中的 Accordion ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21484248/

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