直接从另一个页面链接到一个jQuery选项卡? [英] Link directly to a jQuery tab from another page?

查看:172
本文介绍了直接从另一个页面链接到一个jQuery选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们开始说我熟练的HTML和CSS,但这个jQuery的东西对我来说是新的。所以这可能很容易解决,我已经看过其他答案,但我不能得到它的悬念。

Let's begin by saying I'm skilled in HTML and CSS, but this jQuery stuff is kind of new to me. So this might be really easy to fix and I've looked at other answers but I can't get the hang of it.

我有一个jQuery选项卡表设置有四个标签,如下所示:

I have a jQuery tab table set up with four tabs, like so:

<ul class="tabs">
    <li>
        <a rel="tab_1">Education Insurance</a>
    </li>
    <li>
        <a rel="tab_2">Home Insurance</a>
    </li>
    <li>
        <a rel="tab_3">Car Insurance</a>
    </li>
    <li>
        <a rel="tab_4">Business Insurance</a>
    </li>
</ul>

每个标签的内容位于下面的单独的div标签中,如下所示:

The content for each tab is in a separate div tag below it, like so:

<div class="panes">
    <div id="tab_1" class="tab-content">
        <p>Tab content goes here.</p>
    </div>

我要做的是在首页上创建一个链接,可以直接链接到标签2或标签3,它们位于单独的页面上。

What I'm trying to do is create a link on the homepage that can link directly to tab 2 or tab 3, which are on a separate page. Can anyone help with this?

推荐答案

你可以使用jQuery UI标签,这是自动的。

You can use jQuery UI tabs, thats does that automatically.

以下是工作小提琴

标签链接

第一个标签

第二个标签

第三个标签

参考: JQuery UI选项卡

更好的是,您可以更改select上的哈希,可以复制这样的URL本身

Even better you can change the hash on select so that users can copy the url themselves like this

$('#tabs').tabs({
    select: function(event, ui) {
        window.location.hash = ui.tab.hash;
    }
});

​

这篇关于直接从另一个页面链接到一个jQuery选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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