使用 jQuery 选项卡作为站点导航器?

发布于 2024-07-29 01:39:41 字数 591 浏览 2 评论 0原文

我想使用 jQuery 选项卡作为导航器,即选项卡实际上不应包含任何内容,但相反,当用户单击所有其他选项卡然后单击当前选项卡时,它应该导航到另一个页面。

另外,当到达该页面时,我希望第二个选项卡在加载时应该可见。

示例:

Page1.aspx:

    Page1    |    Page2    |    Page3    |    Page4
Page1 content|    blank    |    blank    |    blank

第 2、3 和 4 页的选项卡标题应该只是指向相应页面的链接。

Page2.aspx:

    Page1    |    Page2    |    Page3    |    Page4
    blank    |Page2 content|    blank    |    blank

第 1、3 和 4 页的选项卡标题应该只是指向相应页面的链接。

等等。

我想将选项卡寻呼机放置在母版页中,然后在每个页面各自的选项卡中填写内容,并将其他选项卡留空。

I want to use jQuery tabs as a navigator, i.e. the tabs shouldn't actually contain anything but instead, when user clicks all the other tabs then the current, it should navigate to another page.

Also, when arriving to that page, I want that second tab shoould be visible onload.

Example:

Page1.aspx:

    Page1    |    Page2    |    Page3    |    Page4
Page1 content|    blank    |    blank    |    blank

The tab titles for page 2, 3 and 4 should be just links to the appropriate page.

Page2.aspx:

    Page1    |    Page2    |    Page3    |    Page4
    blank    |Page2 content|    blank    |    blank

The tab titles for page 1, 3 and 4 should be just links to the appropriate page.

And so on.

I want to place the tabs pager in a master page, then fill-in the content in each page its respective tab and leave the others blank.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清风挽心 2024-08-05 01:39:41

你确定不想要这样的东西吗:

<ul>
    <li><a href="somepage1.aspx" class="selected">Link 1</a></li>
    <li><a href="somepage2.aspx">Link 2</a></li>
    <li><a href="somepage3.aspx">Link 3</a></li>
    <li><a href="somepage4.aspx">Link 4</a></li>
</ul>
<div id="content1">
    <p>Some content for page 1</p>
</div>

我不明白你使用 jQuery 的目的是什么?...

Are you sure you don't want something like this:

<ul>
    <li><a href="somepage1.aspx" class="selected">Link 1</a></li>
    <li><a href="somepage2.aspx">Link 2</a></li>
    <li><a href="somepage3.aspx">Link 3</a></li>
    <li><a href="somepage4.aspx">Link 4</a></li>
</ul>
<div id="content1">
    <p>Some content for page 1</p>
</div>

I don't see what you're using jQuery for?...

辞别 2024-08-05 01:39:41

jQuery 支持通过 ajax 加载内容,只需将 A 链接指向 url 而不是 div id 即可。 但据我所知,没有办法真正让它转到另一个页面。 您可能最好只使用选项卡的现有 css 定义,而不使用 ui 选项卡插件

UPDATE。 这是选项卡的基本 html/css 模型。 您将需要下载 jquery ui 的副本,以便获得 CSS 和图像,但这是制作选项卡的骨架。

<ul class="ui-tabs-nav">
    <li class="ui-tabs-nav-item ui-tabs-selected"><a href="/">Home</a></li>
    <li class="ui-tabs-nav-item"><a href="/somepage.html">Some Page</a></li>
</ul>

jQuery supports loading of content via ajax, simply by pointing the A link to a url instead of a div id. But as far as I know there is no way to actually make it go to another page. You're probably better off just using the existing css definitions for the tabs and not using the ui tabs plugin

UPDATE. This is the basic html/css mockup for the tabs. You will need to download a copy of jquery ui so you get the css and images, but this is the skeleton which makes the tabs.

<ul class="ui-tabs-nav">
    <li class="ui-tabs-nav-item ui-tabs-selected"><a href="/">Home</a></li>
    <li class="ui-tabs-nav-item"><a href="/somepage.html">Some Page</a></li>
</ul>
酒中人 2024-08-05 01:39:41

受到 Mark 的回答的启发,经过一些尝试和错误并深入研究 jQuery UI CSS 文件,我得到了以下内容,可以使用 jQuery UI 自己的样式进行工作。

<div id = "nav-bar" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  <ul class = "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
    <li class = "ui-state-default ui-corner-top ui-tabs-selected ui-state-active">Current Tab</li>
    <li class = "ui-state-default ui-corner-top"><a href="/some_page">To Some Page</a></li>
  </ul>
</div>

然后在另一个CSS文件中添加这个

#nav-bar.ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding: .5em 1em !important;}

Inspired by Mark's answer, and after some trial and error and digging through the jQuery UI CSS file, I got the following to work using jQuery UI's own styles.

<div id = "nav-bar" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  <ul class = "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
    <li class = "ui-state-default ui-corner-top ui-tabs-selected ui-state-active">Current Tab</li>
    <li class = "ui-state-default ui-corner-top"><a href="/some_page">To Some Page</a></li>
  </ul>
</div>

and in another CSS file add this

#nav-bar.ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding: .5em 1em !important;}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文