Home >Web Front-end >Bootstrap Tutorial >Where to set bootstrap carousel time

Where to set bootstrap carousel time

尚
Original
2019-07-31 14:05:395708browse

Where to set bootstrap carousel time

BootStrap carousel chart official code:

<!--data-ride设置图片切换方式为滑动 -->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- 设置轮播图的数量和顺序-->
  <!--data-target的值应与上面的id值对应 -->
  <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>

  <!-- 要展示的图片信息 -->
  <div class="carousel-inner" role="listbox">
    <div class="item active">
      <img src="..." alt="...">
      <div class="carousel-caption">
        ...
      </div>
    </div>
    <div class="item">
      <img src="..." alt="...">
      <div class="carousel-caption">
        ...
      </div>
    </div>
    ...
  </div>

  <!-- 控制图标 -->
  <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>

Implement carousel chart time interval Two ways to change:

1. Add an attribute data-interval="millisecond" after data-ride, where millisecond is the number of milliseconds that need to be set, as follows:

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="1000">

Use JavaScript statements to implement:
The code given by the official website is:

$(&#39;.carousel&#39;).carousel({interval: 2000});

It cannot be implemented directly using this code. A function expression should be added in front of the method, as follows:

$(function(){
	$(&#39;#carousel-example-generic&#39;).carousel({interval:1000});});

Recommended: Bootstrap Getting Started Tutorial

The above is the detailed content of Where to set bootstrap carousel time. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn