Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 引导折叠导航栏在JSFIDLE上工作,不';我不能在实际的网站上工作_Javascript_Jquery_Twitter Bootstrap_Navbar - Fatal编程技术网

Javascript 引导折叠导航栏在JSFIDLE上工作,不';我不能在实际的网站上工作

Javascript 引导折叠导航栏在JSFIDLE上工作,不';我不能在实际的网站上工作,javascript,jquery,twitter-bootstrap,navbar,Javascript,Jquery,Twitter Bootstrap,Navbar,我通常不用问就能找到简单问题的答案,但这次不行。已经好几天了,所以我想我应该问一下 我的html代码如下: 你会看到,我试着做了一些事情来让你明白到底出了什么问题 我测试以确保js库正在加载(Google和jquery) 我尝试从bootstrap网站重新下载bootstrap.min.js(无更改) 我尝试通过CDN获取bootstrap.min.js 我确信答案很简单,但我不太明白(底部的JSFIDLE链接) 任何帮助都将不胜感激 <!DOCTYPE html>

我通常不用问就能找到简单问题的答案,但这次不行。已经好几天了,所以我想我应该问一下

我的html代码如下:

  • 你会看到,我试着做了一些事情来让你明白到底出了什么问题
  • 我测试以确保js库正在加载(Google和jquery)
  • 我尝试从bootstrap网站重新下载bootstrap.min.js(无更改)
  • 我尝试通过CDN获取bootstrap.min.js
  • 我确信答案很简单,但我不太明白(底部的JSFIDLE链接)
任何帮助都将不胜感激

    <!DOCTYPE html>
    <html>
    <head>
        <!-- Import all the necessary stylesheets-->
        <meta name="viewport" content ="width=device-width, inital-scale=1.0">
        <meta charset="utf-8">
        <title>This is the title</title>
        <link rel="stylesheet" href="css/bootstrap.css" type="text/css">
        <link href='http://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'>
        <link href="css/styles.css" media="screen" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" href="fonts/font-awesome/css/font-awesome.min.css">
        <!--<link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">-->
        <!-- <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> -->

        <style type="text/css">
            html, body {
                font-family: "Lato";
                height: 100%;
                margin-bottom: 100px;
            }
        </style>

    </head>

    <body>
        <!--Navigation bar-->
        <div class="row-fluid">
            <div class = "navbar navbar-inverse navbar-fixed-top">
                <div class = "container">
                    <a href = "#" class = "navbar-brand">brand</a>

                    <!--Collapse menu with three lines-->
                    <button type = "button" class = "navbar-toggle" data-toggle = "collapse" data-target = ".navHeaderCollapse">
                        <span class = "icon-bar"></span>
                        <span class = "icon-bar"></span>
                        <span class = "icon-bar"></span>
                    </button>

                    <!--Actual menu-->
                    <div class ="collapse navbar-collapse navHeaderCollapse">
                        <ul class = "nav navbar-nav navbar-right">
                            <li class = "active"><a href = "#">Home</a></li>
                            <li><a href = "#">Blog</a></li>
                            <li><a href = "#">About</a></li>
                            <li><a href = "#contact">Contact</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>




        <!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>-->
        <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
        <!--<script src=”js/bootstrap.js”></script>-->
        <script src=”js/bootstrap.min.js”></script>
        <script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
        <!--use code below to check if javasciprt library loaded-->
        <!--<script type="text/javascript">
        if (typeof jQuery != 'undefined') {
        alert("jQuery library is loaded!");
        }else{
        alert("jQuery library is not found!");
        }
        </script>-->
    </body>
</html>

这是标题
html,正文{
字体系列:“Lato”;
身高:100%;
边缘底部:100px;
}

这是JSFIDLE的工作原理-

在一行中修复错误的撇号:

<script src=”js/bootstrap.min.js”></script>


为什么要加载bootstap.min.js两次?

尝试在此处仅使用一个Bootstrap js版本,以便删除:

<script src=”js/bootstrap.min.js”></script>

并且只保留:

<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

有两种可能,在控制台上显示错误:

  • 您在
  • 您不托管页面,而是使用
    文件://
    方案查看页面
  • 无论如何,固定代码如下:

    <!DOCTYPE html>
    <html>
    <head>
        <!-- Import all the necessary stylesheets-->
        <meta name="viewport" content ="width=device-width, inital-scale=1.0">
        <meta charset="utf-8">
        <title>This is the title</title>
        <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" type="text/css">
        <link href='http://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'>
        <link href="css/styles.css" media="screen" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.min.css">
        <!--<link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">-->
        <!-- <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> -->
    
        <style type="text/css">
            html, body {
                font-family: "Lato";
                height: 100%;
                margin-bottom: 100px;
            }
        </style>
    
    </head>
    
    <body>
        <!--Navigation bar-->
        <div class="row-fluid">
            <div class = "navbar navbar-inverse navbar-fixed-top">
                <div class = "container">
                    <a href = "#" class = "navbar-brand">brand</a>
    
                    <!--Collapse menu with three lines-->
                    <button type = "button" class = "navbar-toggle" data-toggle = "collapse" data-target = ".navHeaderCollapse">
                        <span class = "icon-bar"></span>
                        <span class = "icon-bar"></span>
                        <span class = "icon-bar"></span>
                    </button>
    
                    <!--Actual menu-->
                    <div class ="collapse navbar-collapse navHeaderCollapse">
                        <ul class = "nav navbar-nav navbar-right">
                            <li class = "active"><a href = "#">Home</a></li>
                            <li><a href = "#">Blog</a></li>
                            <li><a href = "#">About</a></li>
                            <li><a href = "#contact">Contact</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    
    
    
    
        <!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>-->
        <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
        <!--<script src=”js/bootstrap.js”></script>-->
        <script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
        <!--use code below to check if javasciprt library loaded-->
        <!--<script type="text/javascript">
        if (typeof jQuery != 'undefined') {
        alert("jQuery library is loaded!");
        }else{
        alert("jQuery library is not found!");
        }
        </script>-->
    </body>
    
    
    这是标题
    html,正文{
    字体系列:“Lato”;
    身高:100%;
    边缘底部:100px;
    }