jQuery UI选项卡:即使定义了选项卡,也不匹配片段标识符

时间:2013-08-21 07:02:55

标签: jquery jquery-ui tabs jquery-ui-tabs

我在文档中定义了以下标签。

<div class="bill-selection-tab">
                <ul>
                    <li class="tab active">
                        <div class="tab_left"></div>
                        <div class="tab_right"></div>
                        <div class="tab_proper">
                            <img alt="open-bills" src="images/open-bill-active.png"/>
                            <a href="#open-tab">OPEN</a>
                        </div>
                    </li>
                    <li class="tab">
                        <div class="tab_left"></div>
                        <div class="tab_proper">
                            <img alt="settled-bills" src="images/settled-bill.png"/>
                            <a href="#settled-tab">SETTLED</a>
                        </div>
                        <div class="tab_right"></div>
                    </li>
                    <li class="tab">
                        <div class="tab_left"></div>
                        <div class="tab_proper">
                            <img alt="cancel-bills" src="images/cancelled-bill.png"/>
                            <a href="#closed-tab">CANCEL</a>
                        </div>
                        <div class="tab_right"></div>
                    </li>
                </ul>
            </div>

<div id="open-tab">
                    <!-- Bill list -->
                    <div class="bill-list">

                    </div>
                    <!-- End of Bill list -->
                </div>

                <div id="closed-tab">
                    <!-- Bill list -->
                    <div class="bill-list">

                    </div>
                    <!-- End of Bill list -->
                </div>

                <div id="settled-tab">
                    <!-- Bill list -->
                    <div class="bill-list">

                    </div>
                    <!-- End of Bill list -->
                </div>

已定义所需的选项卡但仍引发异常。我在这里做错了什么!

1 个答案:

答案 0 :(得分:2)

问题是目标元素不在tab元素bill-selection-tab内。

尝试

<div class="bill-selection-tab">
    <ul>
        <li class="tab active">
            <div class="tab_left"></div>
            <div class="tab_right"></div>
            <div class="tab_proper">
                <img alt="open-bills" src="images/open-bill-active.png"/>
                <a href="#open-tab">OPEN</a>
            </div>
        </li>
        <li class="tab">
            <div class="tab_left"></div>
            <div class="tab_proper">
                <img alt="settled-bills" src="images/settled-bill.png"/>
                <a href="#settled-tab">SETTLED</a>
            </div>
            <div class="tab_right"></div>
        </li>
        <li class="tab">
            <div class="tab_left"></div>
            <div class="tab_proper">
                <img alt="cancel-bills" src="images/cancelled-bill.png"/>
                <a href="#closed-tab">CANCEL</a>
            </div>
            <div class="tab_right"></div>
        </li>
    </ul>

    <div id="open-tab">
        <!-- Bill list -->
        <div class="bill-list">

        </div>
        <!-- End of Bill list -->
    </div>

    <div id="closed-tab">
        <!-- Bill list -->
        <div class="bill-list">

        </div>
        <!-- End of Bill list -->
    </div>

    <div id="settled-tab">
        <!-- Bill list -->
        <div class="bill-list">

        </div>
        <!-- End of Bill list -->
    </div>
</div>

演示:Fiddle