Twitter Bootstrap警报关闭不起作用

时间:2013-12-06 09:39:41

标签: javascript jquery twitter-bootstrap-3

我使用Bootstrap 3.0.3和JQuery 2.0.3

我的HTML代码

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <!--[if IE]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Encoding" content="gzip" />
    <meta http-equiv="Accept-Encoding" content="gzip, deflate" />
    <title>@L("CONTROL_PANEL") | @ViewBag.Title</title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <meta content="L" />
    @Styles.Render("~/content/admin/css")
    <link type="text/css" href="/Content/jquery.mCustomScrollbar.css" rel="stylesheet" media="all" />
    @RenderSection("css", false)
</head>
<body>
    <section id="container">
        <header class="navbar navbar-fixed-top">
            <div class="title">
                <span>@L("CONTROL_PANEL")</span>
            </div>
        </header>
        <aside class="sidebar">
            <menu class="fisrt">
                <li class="active">
                    <a href="#">
                        <i class="fa fa-2x fa-tachometer"></i>
                        @L("PANEL")
                    </a>
                    <span class="separator"></span>
                </li>
            </menu>
            <menu class="second">
                @RenderSection("second_menu", false)
            </menu>
        </aside>
        <menu class="breadcrumb">
            <li><a href="#"><span>Панель</span></a></li>
            <li><a href="#"><span>Новости</span></a></li>
        </menu>
        <section class="main-content">
            <div class="panel panel-dark">
                <div class="panel-heading">
                    <h3 class="panel-title">@ViewBag.PanelTitle</h3>
                </div>
                <div class="panel-body">
                    <div class="content">
                        @{
                            if (this.TempData["Success"] != null)
                            {
                                <div class="alert alert-success fade in">
                                    <a href="#" class="close close-sm" data-dismiss="alert" aria-hidden="true">
                                        <i class="fa fa-times"></i>
                                    </a>
                                    <h4>
                                        <i class="fa fa-check-circle"></i> @L("SUCCESS")
                                    </h4>
                                    <p>@this.TempData["Success"]</p>
                                </div>
                            }

                            if (this.TempData["Error"] != null)
                            {
                            <div class="alert alert-danger fade in">
                                <button type="button" class="close close-sm" data-dismiss="alert">
                                    <i class="fa fa-times"></i>
                                </button>
                                <strong>Oh snap!</strong> Change a few things up and try submitting again.

                            </div>
                            }
                        }
                        <div>
                            @RenderBody()
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <footer>
            Время генерации страницы @TempData["Time"]
        </footer>
    </section>
    <!-- Scripts -->
    @Scripts.Render("~/js")

    <!-- the jScrollPane script -->
    <script type="text/javascript" src="/scripts/jquery.mCustomScrollbar.concat.min.js"></script>
    @RenderSection("js", false)
    <script type="text/javascript">
        (function ($) {
            $(window).load(function () {
                $(".content > div").mCustomScrollbar({
                    theme: "dark-thick",
                    advanced: {
                        autoScrollOnFocus: false,
                        updateOnContentResize: true
                    }
                });


            });
        })(jQuery);   
    </script>
</body>
</html>

当我尝试关闭消息时,我收到错误

  

TypeError:elem.getAttribute不是函数。

     

elem.getAttribute(name):jquery-2.0.3.js(строка1707)

更新

我不知道为什么但如果将Jquery从NuGet更改为谷歌开始工作。

1 个答案:

答案 0 :(得分:1)

  

我不知道为什么但如果将Jquery从NuGet更改为谷歌开始工作。

谷歌为您提供最新的jQuery 1.x。在使用2.0.3之前。 Bootstrap仅支持1.x版本。 (jQuery 2.x放弃了对IE8的支持,Bootstrap仍支持此功能。)

另见:http://getbootstrap.com/getting-started。基本示例模板包括https://code.jquery.com/jquery.js,它提供版本1.10.2。

https://github.com/twbs/bootstrap/blob/v3.0.3/bower.json向您显示Bootstrap 3.0.3要求&gt; = 1.9.0