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 相关文章推荐
javascript 导出数据到Excel(处理table中的元素)
Dec 18 Javascript
JQuery魔力之$(&quot;tagName&quot;)与selector
Mar 05 Javascript
JQuery+CSS提示框实现思路及代码(纯手工打造)
May 07 Javascript
怎么清空javascript数组
May 11 Javascript
深入理解Javascript作用域与变量提升
Dec 09 Javascript
javascript跨域的4种方法和原理详解
Apr 08 Javascript
jquery.cookie实现的客户端购物车操作实例
Dec 24 Javascript
JavaScript实现搜索框的自动完成功能(一)
Feb 25 Javascript
ClearTimeout消除闪动实例代码
Feb 29 Javascript
Boostrap入门准备之border box
May 09 Javascript
关于vue.extend和vue.component的区别浅析
Aug 16 Javascript
在Vue中使用this.$store或者是$route一直报错的解决
Nov 08 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中$_GET与$_POST过滤sql注入的方法
2014/11/03 PHP
php防止网站被刷新的方法汇总
2014/12/01 PHP
php绘制一个矩形的方法
2015/01/24 PHP
php删除数组指定元素实现代码
2017/05/03 PHP
php实现简单的守护进程创建、开启与关闭操作
2019/08/13 PHP
基于laravel where的高级使用方法
2019/10/10 PHP
jQuery动态添加 input type=file的实现代码
2012/06/14 Javascript
jquery更换文章内容与改变字体大小代码
2013/09/30 Javascript
JavaScript的事件绑定(方便不支持js的时候)
2013/10/01 Javascript
js实现仿QQ秀换装效果的方法
2015/03/04 Javascript
jQuery实现简洁的导航菜单效果
2015/11/23 Javascript
限制复选框最多选择项的实现代码
2016/05/30 Javascript
JQuery的attr 与 val区别
2016/06/12 Javascript
JS控制文本域只读或可写属性的方法
2016/06/24 Javascript
想学习javascript JS和jQuery哪个重要 先学哪个
2016/12/11 Javascript
开源免费天气预报接口API及全国所有地区代码(国家气象局提供)
2016/12/26 Javascript
关于jQuery EasyUI 中刷新Tab选项卡后一个页面变形的解决方法
2017/03/02 Javascript
jquery mobile实现可折叠的导航按钮
2017/03/11 Javascript
微信小程序中setInterval的使用方法
2017/09/29 Javascript
webstrom Debug 调试vue项目的方法步骤
2018/07/17 Javascript
解决layui表格内文本超出隐藏的问题
2019/09/12 Javascript
layui使用表格渲染获取行数据的例子
2019/09/13 Javascript
[00:20]TI9观赛名额抽取Ⅱ
2019/07/24 DOTA
使用Python的Twisted框架编写简单的网络客户端
2015/04/16 Python
Python简单爬虫导出CSV文件的实例讲解
2018/07/06 Python
python 处理微信对账单数据的实例代码
2019/07/19 Python
利用Python实现斐波那契数列的方法实例
2020/07/26 Python
Python3爬虫发送请求的知识点实例
2020/07/30 Python
美国汽配连锁巨头Pep Boys官网:轮胎更换、汽车维修服务和汽车零部件
2017/01/14 全球购物
size?荷兰官方网站:英国高级运动鞋精品店
2020/07/24 全球购物
医学护理系毕业生求职信
2013/10/01 职场文书
网络维护管理员的自我评价分享
2013/11/11 职场文书
岗位竞聘演讲稿
2014/01/10 职场文书
大学旷课检讨书
2014/01/28 职场文书
2014年社区植树节活动方案
2014/02/28 职场文书
分享python函数常见关键字
2022/04/26 Python