我是jquery和bootstrap的新手,我无法让它们彼此玩得很好。我有一个页面,其中同时包含Bootstrap下拉列表和jquery滑块。但是,我不能让他们两个同时工作。

bootstrap 下拉菜单与此文件一起使用,并且滑块会破坏

<html lang="en">
<head>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" media="all" />
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js" type="text/javascript"></script>
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <script src="/js/slider_input.js"></script>
</head>

<body>
....
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script src="/bootstrap/js/bootstrap.min.js"></script>

</body
</html

通过删除倒数第二行,如下所示:

滑块正常工作,并且 bootstrap 下拉菜单中断
<html lang="en">
<head>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" media="all" />
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js" type="text/javascript"></script>
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <script src="/js/slider_input.js"></script>
</head>

<body>
....

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

</body
</html

最佳答案

哦,是的,现在我明白了。您必须先加载实际的jquery,否则UI也不起作用。所以这应该是负责人

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js" type="text/javascript"></script>
<script src="/bootstrap/js/bootstrap.min.js"></script>
<script src="/js/slider_input.js"></script>

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" media="all" />
<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">

同样在html5中,您需要省略'type =“text/javascript”',就像 bootstrap 一样,也要包含在内,因此,如果您将其放在另一个 bootstrap 上,也将其添加到 bootstrap 中,则与加载有关规则。

关于javascript - 具有 bootstrap 的jQuery的脚本顺序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16926086/

10-09 18:04
查看更多