实例 Bootstrap .carousel("prev") 与 .carousel("next") 方法

x
 
<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css">
  <script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
  <script src="https://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>
  <style>
  .carousel-inner > .item > img,
  .carousel-inner > .item > a > img {
    width: 70%;
    margin: auto;
  }
  </style>
</head>
<body>
<div class="container">
  <h2>Carousel Methods</h2>
  <p>The <strong>prev</strong> method goes to the previous item.</p>
  <p>The <strong>next</strong> method goes to the next item.</p>
  <button type="button" id="myBtn" class="btn btn-success btn-lg" id="myBtn">Previous Item</button>
  <button type="button" id="myBtn2" class="btn btn-danger btn-lg" id="myBtn">Next Item</button><br><br>
  <div id="myCarousel" class="carousel slide">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li class="item1 active"></li>
      <li class="item2"></li>
      <li class="item3"></li>
      <li class="item4"></li>
    </ol>
    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
      <div class="item active">
        <img src="/images/img_chania.jpg" alt="Chania" width="460" height="345">
      </div>
      <div class="item">
        <img src="/images/img_chania2.jpg" alt="Chania" width="460" height="345">

输出结果