Bootstrap 3 Carousel字幕延迟

Bootstrap 3 Carousel Caption Delay

本文关键字:延迟 字幕 Carousel Bootstrap      更新时间:2023-09-26

网站:http://freedomcreativesolutions.com/old/steamsource/

问题:试图将javascript slide.bs.carousel实现到代码中,使标题延迟并在幻灯片中加载图片后几秒钟出现。我输入了"slide.bs"的代码。Carousel '在结束主体标记之前的script标记中,而不是在单独的js文件中。但它似乎根本不工作,仍然随着图片出现。

我做了什么:http://jsfiddle.net/fuhs3smx/

似乎它在Jsfiddle(这个程序的新手)中不起作用,这就是为什么我给了网站的链接,所以你们至少知道我想要完成什么。

猜猜我在这里想问的是,我到底应该把'slide.bs.carousel'的脚本放在哪里?在我看来一切都很好,我猜是我把脚本放在了错误的地方。

<div id="carousel-example-generic" class="carousel slide carousel-fade" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
    <li data-target="#carousel-example-generic" data-slide-to="2"></li>
  </ol>
  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="item active">
      <img src="./img/family-new.jpg" alt="We are Serious about Clean!">
      <div class="carousel-caption">
       <h3>Safe for the whole family!</h3>
      </div>
    </div>
    <div class="item">
      <img src="./img/RugCleaningFacility.jpg" alt="Rug Cleaning">
      <div class="carousel-caption">
       <h3>State of the art rug cleaning facility!</h3>
      </div>
    </div>
    <div class="item">
      <img src="./img/ProfessionalWW.jpg" alt="Window Washing and Pressure Washing">
      <div class="carousel-caption">
      <h3>Professional Window Washing and Pressure Washing!</h3>
      </div>
    </div>
    <div class="item">
      <img src="./img/UpholsteryClean.jpg" alt="Upholstery Cleaning">
      <div class="carousel-caption">
       <h3>The deepest upholstery cleaning available!</h3>
      </div>
    </div>
  </div>
  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

更新:在包括bootstrap.min.js之后,我在启动开发工具时得到这个消息:

Uncaught TypeError: undefined is not a function

carouselContainer.carousel({
    interval: slideInterval,
    cycle: true,
    pause: "hover"
}).on('slid.bs.carousel', function() {
    toggleCaption();
});

那是什么意思?也许我拼错了什么,或者位置完全错了。

您的小提琴没有包含Bootstrap.js。你还必须包含jQuery,因为Bootstrap.js需要jQuery。

Uncaught TypeError: jQuery.easing[this.easing] is not a function问题可以通过添加jQuery UI来解决。

你会注意到我也把你的JS放在.ready()中,这样它就可以保证在DOM准备好后执行。

我已经更新了小提琴供你复习。http://jsfiddle.net/yongchuc/fuhs3smx/2/