twitter-bootstrap 数据切换和数据目标未按预期工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35239736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 23:36:51  来源:igfitidea点击:

Data-toggle and Data-target are not working as desired

javascriptjqueryasp.nettwitter-bootstrap

提问by starklord

I have sample navigation bar. But I couldn't collapse it as the 'data-toggle' and 'data-target' are not working. Please help me and also give suggestion if there is any other issue in my code. Here is the code:

我有示例导航栏。但我无法折叠它,因为“数据切换”和“数据目标”不起作用。如果我的代码中存在任何其他问题,请帮助我并提出建议。这是代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="/css/bootstrap.min.css" />
    
    <title>Basic Log In Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="Default.aspx" ><span><img alt="logo" src="Images/logo.png" height="30" /></span>BootStrap Demo</a>
                </div>
                <div id="navbar" class="navbar-collapse collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li class="active"><a href="Default.aspx">Home</a></li>
                        <li><a href="#">About</a></li>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Social</a>
                            <ul class="dropdown-menu">
                                <li><a href="#">facebook</a></li>
                                <li><a href="#">Twitter</a></li>
                                <li><a href="#">Google+</a></li>
                                <li><a href="#">Instagram</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    </form>
    <script type="text/javascript" src="/js/bootstrap.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/jquery-1.12.0.min.js"></script>
</body>
</html>

采纳答案by Atilla Arda A??kg?z

i created your example at bootply and it works just fine. So all i can see here now is that your bootstrap js might not be loading. First add it above the page after bootstrap css and then you should be fine . Check it here http://www.bootply.com/z2FXC4SKJn

我在 bootply 上创建了你的例子,它工作得很好。所以我现在在这里只能看到你的引导 js 可能没有加载。首先在 bootstrap css 之后将它添加到页面上方,然后你应该没问题。在这里检查http://www.bootply.com/z2FXC4SKJn