JS实现touch 点击滑动轮播实例代码


Posted in Javascript onJanuary 19, 2017

废话不多说了,直接给大家贴js代码了,具体代码如下所示:

<script src="../js/jquery-1.8.3.min.js"></script>
<script src="../js/jQuery.mobile-1.3.2.min.js"></script>
----------------------需要应用jquery .mobile自行百度
.num-zcon{
  overflow: hidden;
  width:auto;
  height: 12.5em;
}
.num-container1 {
    height: 12.5em;
    background: url("icons/effect-img/13.png")no-repeat;
        background-size: cover;
    display:block;
  }
.num-container2 {
   height: 12.5em;
    background: url("icons/effect-img/15.png")no-repeat;        background-size: cover;
      display:none;
  }
  .num-container3 {
    height: 12.5em;
    background: url("icons/effect-img/177.png")no-repeat;
        background-size: cover;
      display:none;
  }
  .num-container4 {
    height: 12.5em;
    background: url("icons/effect-img/18.png")no-repeat;
        background-size: cover;
      display:none;
  }
  .num-container5 {
    height: 12.5em;
    background: url("icons/effect-img/19.png")no-repeat;
    background-size: cover;
    display:none;
  }
  .num-float{
    height:1em;
    margin:0 auto;
    z-index: 3;
    text-align:center;
    margin-top: -1.35em;
  }
  .num-a{
    background:#ffffff;
    height: 0.4375em;
    width: 0.4375em;
    border-radius: 50%;
    float: left;
    opacity: 0.5;
  }
   .num-kong{
    height: 0.625em;
    width: 0.25em;
    float: left;
  }
  .num-kong-width{
    width: auto;
    height: 0.9375em;
  }
  .num-kong-win{
    height: 0.625em;
    width: 0.1em;
    float: left;
  }
----------
<div class="num-zcon">
  <div class="num-container1" id="adv1">
  </div>
  <div class="num-container2" id="adv2">
  </div>
  <div class="num-container3" id="adv3">
  </div>
  <div class="num-container4" id="adv4">
  </div>
  <div class="num-container5" id="adv5">
  </div>
  <div class="num-float ub ub-ac ub-pc">
    <div class="num-a" id="ab1">
    </div>
    <div class="num-kong">
    </div>
    <div class="num-a" id="ab2">
    </div>
    <div class="num-kong">
    </div>
    <div class="num-a" id="ab3">
    </div>
    <div class="num-kong">
    </div>
    <div class="num-a" id="ab4">
    </div>
    <div class="num-kong">
    </div>
    <div class="num-a" id="ab5">
    </div>
  </div>
</div>
<script>
  //横幅广告;
  var Nownumber = 1;//1图;
  var Maxnumber = 5;//总个数;
  function show() {
    for (var i = 1; i <= Maxnumber; i++) {
      if (Nownumber == i) {
        document.getElementById("adv" + Nownumber).style.display = 'block';
        document.getElementById("ab" + Nownumber).style.opacity = 1;
      }
      else {
        document.getElementById("adv" + i).style.display = 'none';
        document.getElementById("ab" + i).style.opacity = 0.5;
        document.getElementById("adv" + i).style.transition = "1s";
      }
    }
    if (Nownumber == Maxnumber) {
      Nownumber = 1;
    }
    else {
      Nownumber++;
    }
  }
  theTime = setInterval('show()', 5000);
</script>
<script>
$(document).on("pageinit","#pageone",function(){
 $("#adv1").on("swiperight",function(){
  $(this).hide();
  Nownumber=5;
  $("#adv5").show();
 });   
 $("#adv5").on("swiperight",function(){
  $(this).hide();
  Nownumber=4;
  $("#adv4").show();
 }); 
 $("#adv4").on("swiperight",function(){
  $(this).hide();
  Nownumber=3;
  $("#adv3").show();
 }); 
 $("#adv3").on("swiperight",function(){
  $(this).hide();
  Nownumber=2;
  $("#adv2").show();
 }); 
 $("#adv2").on("swiperight",function(){
  $(this).hide();
  Nownumber=1;
  $("#adv1").show();
 }); 
 $("#adv1").on("swipeleft",function(){
  $(this).hide();
  Nownumber=2;
  $("#adv2").show();
  });
 $("#adv2").on("swipeleft",function(){
  $(this).hide();
  Nownumber=3;
  $("#adv3").show();
  });
 $("#adv3").on("swipeleft",function(){
  $(this).hide();
  Nownumber=4;
  $("#adv4").show();
  });
 $("#adv4").on("swipeleft",function(){
  $(this).hide();
  Nownumber=5;
  $("#adv5").show();
  });
 $("#adv5").on("swipeleft",function(){
  $(this).hide();
  Nownumber=1;
  $("#adv1").show();
});
});
</script>

以上所述是小编给大家介绍的JS实现touch 点击滑动轮播实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对三水点靠木网站的支持!

Javascript 相关文章推荐
用于自动添加Digg This!按钮的JavaScript
Dec 23 Javascript
JS小功能(列表页面隔行变色)简单实现
Nov 28 Javascript
node.js中的querystring.unescape方法使用说明
Dec 10 Javascript
PHP中CURL的几个经典应用实例
Jan 23 Javascript
js随机生成网页背景颜色的方法
Feb 26 Javascript
JS获得图片alt信息的方法
Apr 01 Javascript
详解AngularJS中的依赖注入机制
Jun 17 Javascript
Bootstrap Table的使用总结
Oct 08 Javascript
ActiveX控件的使用-js实现打印超市小票功能代码详解
Nov 22 Javascript
vue.js中引入vuex储存接口数据及调用的详细流程
Dec 14 Javascript
vue项目部署上线遇到的问题及解决方法
Jun 10 Javascript
js+css3实现炫酷时钟
Aug 18 Javascript
微信小程序 视图容器组件的详解及实例代码
Jan 19 #Javascript
详解前端构建工具gulpjs的使用介绍及技巧
Jan 19 #Javascript
js实现漫天星星效果
Jan 19 #Javascript
ajax 提交数据到后台jsp页面及页面跳转问题
Jan 19 #Javascript
ajax与json 获取数据并在前台使用简单实例
Jan 19 #Javascript
javaScript基础详解
Jan 19 #Javascript
bootstrap css样式之表单
Jan 19 #Javascript
You might like
使用PHP数组实现无限分类,不使用数据库,不使用递归.
2006/12/09 PHP
PHP Zip解压 文件在线解压缩的函数代码
2010/05/26 PHP
php中session定期自动清理的方法
2015/11/12 PHP
php pdo oracle中文乱码的快速解决方法
2016/05/16 PHP
PHP使用自定义方法实现数组合并示例
2016/07/07 PHP
php异常处理捕获错误整理
2019/09/23 PHP
Gambit vs CL BO3 第二场 2.13
2021/03/10 DOTA
Flash对联广告的关闭按钮讨论
2007/01/30 Javascript
JavaScript 解析Json字符串的性能比较分析代码
2009/12/16 Javascript
Jquey拖拽控件Draggable使用方法(asp.net环境)
2010/09/28 Javascript
TimergliderJS 一个基于jQuery的时间轴插件
2011/12/07 Javascript
jquery在Chrome下获取图片的长宽问题解决
2013/03/20 Javascript
js实现搜索框关键字智能匹配代码
2020/03/26 Javascript
javascript RegExp 使用说明
2016/05/21 Javascript
Web打印解决方案之普通报表打印功能
2016/08/29 Javascript
详解js的事件代理(委托)
2016/12/22 Javascript
vue.js从安装到搭建过程详解
2017/03/17 Javascript
mongoose中利用populate处理嵌套的方法
2017/05/26 Javascript
vue中appear的用法
2017/08/17 Javascript
详解性能更优越的小程序图片懒加载方式
2018/07/18 Javascript
node.js命令行教程图文详解
2019/05/27 Javascript
vue使用swiper实现中间大两边小的轮播图效果
2019/11/24 Javascript
JavaScript this关键字指向常用情况解析
2020/09/02 Javascript
Python常用时间操作总结【取得当前时间、时间函数、应用等】
2017/05/11 Python
Python 12306抢火车票脚本 Python京东抢手机脚本
2018/02/06 Python
python3安装speech语音模块的方法
2018/12/24 Python
Python button选取本地图片并显示的实例
2019/06/13 Python
python连接、操作mongodb数据库的方法实例详解
2019/09/11 Python
python3用PyPDF2解析pdf文件,用正则匹配数据方式
2020/05/12 Python
美国时尚女装在线:Missguided
2016/12/03 全球购物
食堂员工工作职责
2013/12/18 职场文书
大学生创业感言
2014/01/25 职场文书
汽车队司机先进事迹材料
2014/02/01 职场文书
2015年社区工会工作总结
2015/05/26 职场文书
护理心得体会范文
2016/01/22 职场文书
能用CSS实现的就不要麻烦JavaScript了
2021/10/05 HTML / CSS