jquery - 如何在 jquery 中使用选项卡?

标签 jquery css html

我制作了一个网页,我应该使用 jquery 将选项卡放入我的页面。我遇到了问题,经过多次尝试解决后,我失败了。这些选项卡应该链接其中的其他页面。这就是我遇到的问题。

  1. 标签只贴在我的主页上,而不是在每个页面上。
  2. 主页会自行重复,这意味着有两个页面一个接着一个。
  3. 不使用 id 作为 tb-1、tb-2。我将其他页面链接到我的选项卡,但它不起作用。

下面是我的部分代码:

<!DOCTYPE html>
<html lang = "en">
    <head>
        <meta charset="utf-8">
        <title> Underwater World    </title>

        <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">

        <script src="//code.jquery.com/jquery-1.10.2.js"></script>

        <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
        <link rel="stylesheet"href="ppcss.css">



        <script>

        $(function() {

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

        });

        </script>
    </head> 

    <body > 
        <div id="tabs">

        <ul>
        <li><a href="">Homepage</a></li>

        <li><a href="animals.html">Animals</a></li>

        <li><a href="Algae.html">Plants</a></li>

        <li><a href="FAQS.html">F.A.Qs</a></li>

        <li><a href="ContactUs.html">Contact us</a></li>

        </ul>

        <div id="wrapper">
        <!-- header -->
        <div id="header">
        <h1 class="head"> Underwater World </h1>
        <h3 class="subhead">
        A New World!
        </h3>
        </div>


        <!-- left column -->
        <div id="leftcol" >

        <div class="smfeature">
        <h4> Who we are. </h4>
        <p> We are a group of marine biologist that study marine life such as animals, plants and coral reefs. This website will provide you with the most accurate information about the life that lives under the water. </P>
        </div>

最佳答案

由于您只将代码添加到您的主页,它只会出现在那里。 jQuery UI 选项卡旨在处理同一页面内的内容,并依赖 ID 和目标链接来创建此功能。要获得所需的结果,您需要引入每个页面的内容并将其放入具有 ID 的容器中,并使用这些 ID 的目标链接。文档页面给出了一个很好的例子:http://jqueryui.com/tabs/#default

关于jquery - 如何在 jquery 中使用选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27299485/

相关文章:

jQuery 驱动的 Accordion 缺少 anchor 链接功能

html - 我的 Github 页面不会将自定义 css 文件应用到网站

javascript - jQuery的幻灯片效果

jquery - 防止内容在滚动条显示/隐藏上水平移动

javascript - 不在 <head> 标记中加载 jQuery 是否有负面影响?

javascript - 为什么我的网站无法在 Iphone 上正确加载?

javascript - 如果未选中,如何删除附加值

javascript - 如何将图片添加到单选按钮

javascript/jquery - 识别从缓存加载

javascript - 为什么 POST 方法在移动 Web 应用程序中不起作用