使用类选择器的 JQuery ui 选项卡

标签 jquery html jquery-ui-tabs

在 jquery ui 演示中,为了链接到某个选项卡,使用了 id 选择器,这在链接中工作正常,因为“#”代表链接中的 anchor 。

但是我想创建多个选项卡面板并使用类选择器链接到正确的选项卡。

<div class="accordion">
    <h3>Product x</h3>
    <div class="tabs">
        <ul>
            <!-- .tabs-0 & .tabs-1 don't work, since they are not a valid url -->
            <li><a href=".tabs-0">General product info</a></li>
            <li><a href=".tabs-1">End user info</a></li>
        </ul>
        <div class="tabs-0">
            general info for product x.
        </div>
        <div class="tabs-1">
            end user info product x.
        </div>
    </div>
</div>
<div class="accordion">
    <h3>Product y</h3>
    <div class="tabs">
        <ul>
            <!-- .tabs-0 & .tabs-1 don't work, since they are not a valid url -->
            <li><a href=".tabs-0">General info</a></li>
            <li><a href=".tabs-1">End user info</a></li>
        </ul>
        <div class="tabs-0">
            general info for product y.
        </div>
        <div class="tabs-1">
            end user info product y.
        </div>
    </div>
</div>

Here是我在 jsfidlle 和 here 中尝试过的是每个面板的外观!

所以问题是我如何通过类名链接到选项卡?

最佳答案

<li><a href=".tabs-0">General product info</a></li>
<li><a href=".tabs-1">End user info</a></li>

问题出在上面的代码上。你can't use class 用于超链接 a 标签。所以更改为 id

关于使用类选择器的 JQuery ui 选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21451482/

相关文章:

javascript - 通过 js 创建时,HTML5 输入类型颜色不显示值

javascript - primefaces jquery ui 选项卡

jquery - 当用户切换选项卡时暂停 html5 视频

jquery - 有哪些优秀的 jQuery 插件可以突出显示代码和 XML 内容?

javascript - 输出数组变量javascript

html - 为什么文本出现在具有高 z-index 的图像上方

html - CSS 溢出 : Force one div to overflow

css - 表中的 jQuery UI 选项卡偏移其他单元格中的内容?

javascript - jQuery UI 选项卡 - 显示所有选项卡

javascript - 单击 Electron 中的按钮打开一个新窗口