Bootstrap Carousel示例模板不起作用

时间:2014-08-12 20:40:54

标签: html twitter-bootstrap

我试图将Carousel示例模板合并到我的项目中:http://getbootstrap.com/examples/carousel/

这是我的HTML。 CSS和JS文件加载正常。为了让您清楚地知道到底缺少什么,这是我的页面:http://i.imgur.com/OvcSKsj.png

<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="icon" href="../../favicon.ico">
    <script src="{{ STATIC_URL }}js/jquery.min.js"></script>
    <link href="{{ STATIC_URL }}css/bootstrap.min.css" rel="stylesheet">
    <link href="{{ STATIC_URL }}css/bootstrap-theme.min.css">
    <script src="{{ STATIC_URL }}js/bootstrap.min.js"></script>
    <title>Carousel Template for Bootstrap</title>
  </head>
<!-- NAVBAR
================================================== -->
<body>
# The body was directly copy-pasted, except that the bootstrap.js and jquery.js 
# files were moved to the top of the page from the bottom for debug convenience
</body>

编辑:我忘了你必须用$(&#39; .carousel&#39;)初始化它.carousel();.我在carousal HTML之前添加了它,但它仍然不起作用。

1 个答案:

答案 0 :(得分:0)

Answered in another post

我会在这里引用它,因为我认为这可能是你的问题。


显然jQuery没有正确加载。 尝试在页面中加载两个脚本。

运行轮播的代码是

<script>
  // Load this when the DOM is ready
$(function(){
  // You used .myCarousel here. 
  // That's the class selector not the id selector,
  // which is #myCarousel
  $('#myCarousel').carousel();
});
</script>

您可以将其放在其他两个脚本之后 或其他脚本现在。

相关问题