是否可以在不使用定位标记和ID的情况下使用制表符? [英] is it possible to use Tabs without using anchor tag and id?

查看:102
本文介绍了是否可以在不使用定位标记和ID的情况下使用制表符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想生成动态标签.因此锚标签将没有 id也div标签不会有id.

i would like to generate dynamic tabs. so anchor tags will not have id also div tags wont have id.

这是我要尝试执行的操作,但不起作用.

<script>

        $(function () {
            $("#tabs").tabs();

            $("#tabs ul.super li a").each(function (index) {
                $(this).click(function () {
                    $("#tabs").tabs("select", index);
                });
            });
        });

    </script>
    <div id="tabs">
        <ul class="super">
            <li><a>title 1</a></li>
            <li><a>title 2 </a></li>
        </ul>
        <div>
            content1
        </div>
        <div>
            content2
        </div>
    </div>

我如何使它像这样工作?

How can i make it work like that?

推荐答案

这是workind代码.动态添加制表符和a

It is workind code. Dynamicaly add tab's and a's

<div id="tabs">
    <ul class="super">
        <li><a>title 1</a></li>
        <li><a>title 2 </a></li>
    </ul>
    <div>
        content1
    </div>
    <div>
        content2
    </div>
</div>
<script>
    $(function () {
        $("#tabs ul.super li a").each(function (index) {
            $(this).attr("href", "#spec" + index.toString());            
        });
        $("#tabs div").each(function (index) {
            $(this).attr("id", "spec" + index.toString());
        })
        $("#tabs").tabs();
    });      
</script>

这篇关于是否可以在不使用定位标记和ID的情况下使用制表符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆