如何通过按住鼠标停止幻灯片播放?

时间:2018-07-13 17:49:08

标签: javascript jquery

该如何通过按住鼠标来停止幻灯片播放?

代码

<section class="testimonials3 cid-qyucOJY58V" id="testimonials3-2" data-rv-view="171">

  <?php
    while($objResult = mysql_fetch_array($query))
    {
  ?>

  <div class="container">
    <div class="w3-content w3-section" style="max-width:100%">
      <img class="mySlides w3-animate-fading" src="A/promotion-image/<?php echo $objResult["promotion_image"];?>" style="max-width:100%">
    </div>
  </div>

  <?php
    }
  ?>

</section>

脚本

<script>
    var myIndex = 0;
    carousel();

    function carousel() {
      var i;
      var x = document.getElementsByClassName("mySlides");
      for (i = 0; i < x.length; i++) {
        x[i].style.display = "none";
      }
      myIndex++;
      if (myIndex > x.length) {myIndex = 1}
      x[myIndex-1].style.display = "block";
      setTimeout(carousel, 10000) ;
    }
</script>

0 个答案:

没有答案