1

我正在尝试使用 Bootstrap CSS Carousel。左右箭头不起作用,幻灯片没有自动切换......我不知道为什么。

这是我的代码:

索引.php

<?php
  include("header.php");
?>
  <body>

  <?php
    include("menu.php");
    include("carousel.php");
  ?>

  <footer>
    <p>&copy; 2013 Company</p>
  </footer>

  <?php
    include("script.php");
  ?>
      <script>
        !function ($) {
          $(function(){
            $('.carousel').carousel()
          })
        }(window.jQuery)
      </script>
  </body>
</html>

轮播.php

<div id="myCarousel" class="carousel slide">
  <div class="carousel-inner">
    <div class="item active">
      <img src="img/bg1.jpg" alt="">
      <div class="container">
        <div class="carousel-caption">
          <h1>ITEM 1</h1>
          <p class="lead">Description 1.</p>
          <a class="btn btn-large btn-primary" href="#">More</a>
        </div>
      </div>
    </div>

    <div class="item">
      <img src="img/bg2.jpg" alt="">
      <div class="container">
        <div class="carousel-caption">
          <h1>ITEM 2</h1>
          <p class="lead">Description 2.</p>
          <a class="btn btn-large btn-primary" href="#">More</a>
        </div>
      </div>
    </div>

    <div class="item">
      <img src="img/bg3.jpg" alt="">
      <div class="container">
        <div class="carousel-caption">
          <h1>ITEM 3</h1>
          <p class="lead">Description 3.</p>
          <a class="btn btn-large btn-primary" href="#">More</a>
        </div>
      </div>
    </div>
  </div>
  <!-- Carousel NAV -->
  <a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>
  <a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div>

script.php(*已编辑)

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

PS:我不能在 JS 中编程,也不能在 JQuery 中编程。

4

1 回答 1

0

我知道了 !

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
  $(document).ready(function(){
      $('.carousel').carousel();
  });
</script>

在页面的开头而不是结尾运行此脚本使其工作。在 script.php 文件中,我运行以下脚本:

<script src="js/bootstrap.js"></script>
<script src="/js/bootstrap-carousel.js"></script>
<script src="/js/jquery.js"></script>
于 2013-03-30T15:24:26.450 回答