Bootstrap js元素在Fiddle中工作,但不在本地工作

时间:2013-07-09 16:08:11

标签: javascript html css twitter-bootstrap

我已经完成了我能想到的几乎所有事情,但是我无法让我的引导元素(即导航折叠和标签)在本地工作。他们都在小提琴中漂亮地工作,所以我很困惑。

小提琴在这里:http://jsfiddle.net/e4RZE/3/

我将js带入我的项目的代码位于页脚下方,如下所示:

<!-- Placed at the end of the document so the pages load faster -->
    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.js"></script>

我的标题代码如下:

<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
    <div class="container">
        <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span>
     <span class="icon-bar"></span>
     <span class="icon-bar"></span>

        </button> <a class="brand" href="http://howard.edu">Project</a>

        <div class="nav-collapse collapse">
            <ul class="nav">
                <li><a href="index.html">Home</a>
                </li>
                <li class="active"><a href="contact.html">Contact</a>
                </li>
                <li><a href="nowplaying.html">Now Playing</a>
                </li>
                <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Public Resources <b class="caret"></b></a>

                    <ul class="dropdown-menu">
                        <li><a href="public.html#observatory">Observatory</a>
                        </li>
                        <li><a href="public.html#planetarium">Planetarium</a>
                        </li>
                        <li class="divider"></li>
                        <li class="nav-header">For Teachers and Schools</li>
                        <li><a href="schools.html#programs">Programs</a>
                        </li>
                        <li><a href="schools.html#events">Host an Event</a>
                        </li>
                        <li><a href="schools.html#education">Educational Initiatives</a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Undergraduate Resources <b class="caret"></b></a>

                    <ul class="dropdown-menu">
                        <li><a href="students.html#observatory">Observatory</a>
                        </li>
                        <li><a href="students.html#planetarium">Planetarium</a>
                        </li>
                        <li class="divider"></li>
                        <li class="nav-header">HU Physics</li>
                        <li><a href="#">Physics Homepage</a>
                        </li>
                        <li><a href="#">Physics and Astronomy</a>
                        </li>
                    </ul>
                </li>
                <li><a href="volunteer.html">Volunteer</a>
                </li>
                <li><a href="faq.html">FAQ</a>
                </li>
            </ul>
        </div>
        <!--/.nav-collapse -->
    </div>
</div>

编辑:Bootstrap.css,bootstrap-responsive.css和我的自定义文件(betterstrap2.css)添加如下:

<link href="css/bootstrap.css" rel="stylesheet">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700 ' rel='stylesheet' type='text/css'>
    <link href="css/betterstrap2.css" rel="stylesheet">
    <link href="css/bootstrap-responsive.css" rel="stylesheet">
提前谢谢。

2 个答案:

答案 0 :(得分:1)

确保您的jquery和bootstrap源文件位于要从这些脚本标记加载的正确位置。

此外,您还应该加载bootstrap.css文件,如果您想在页面上看到漂亮的自举元素:)

答案 1 :(得分:-1)

有javascript错误或指向无效的javascript文件的链接。点击页面上的F12并刷新以查看失败的内容。