zoukankan      html  css  js  c++  java
  • js无限轮播的写法

    js实现轮播很简单,无限轮播也不是很难,掌握技巧就很简单了。

    $(document).ready(function(){
      var x=0;
      var itime;
      var newshop=function(){
      if (x%3==1) {
        $('#shopDiv').animate({'margin-left':-1842.5},1500);
        clearTimeout(itime);
        itime=setTimeout(function(){newshop();x++;}, 6500);
      }else if(x%3==2){
        $('#shopDiv').animate({'margin-left':0},0);
        clearTimeout(itime);
        itime=setTimeout(function(){newshop();x++;}, 0);
      }else if(x%3==0){
        $('#shopDiv').animate({'margin-left':-922},1500);
        clearTimeout(itime);
      itime=setTimeout(function(){newshop();x++;}, 6500);
      }
    }
    itime=setTimeout(function(){newshop();x++;}, 5000);
    $('#shopDiv').mouseover(function(){
    clearTimeout(itime);
    })
    $('#shopDiv').mouseleave(function(){
    clearTimeout(itime);
    itime=setTimeout(function(){newshop();x++;}, 3000);
    })
    })

  • 相关阅读:
    while循环学习之统计流量
    MySQL的启动脚本
    UVA 725 Division
    UVA 712 S-tree
    UVA 514
    字典树
    UVA 1595 multimap 的应用
    C++ map 和 multimap
    浮点数
    UVA 227
  • 原文地址:https://www.cnblogs.com/webwangjie/p/7403873.html
Copyright © 2011-2022 走看看