//轮播图
    function Switcher(obj){
        this.box = $(obj.box);
        this.width = this.box.width();
        this.banner = $(obj.banner);
        this.list = this.banner.find('li');
        this.index = $(obj.btn).find('li').index();
        this.btn = $(obj.btn);
        this.prev1=$(obj.prev);
        this.next1=$(obj.next);
        this.timer = obj.timer;
        this.autoplay = obj.autoplay;
        this.a=0;
        this.b=0;
        this.d = this.list.length;
        this.ani=obj.ani;
        this.change = obj.change;
        this.init();
    }
    Switcher.prototype={
        init:function(){
            this.play = null;
            this.fun();
            if(this.autoplay==true){this.auto();}
            this.prev();
            this.next();
            this.list.eq(0).css({zIndex:1});
            this.btn.find('li').eq(0).addClass(this.change);
        },
        fun:function(){
            var _this = this;
            for(var i = 0;i<_this.list.length;i++){
                _this.btn.append('<li></li>')
            }
            _this.btn.find('li').on('click',function(){
                clearInterval(_this.play);
                _this.a = $(this).index();
                $(this).addClass(_this.change).siblings().removeClass(_this.change);
                _this.list.eq(_this.a).css(comm.blind_event(_this.ani,0.8,0)).show().siblings().hide();
            });
        },
        auto:function(){
            var _this = this;
            this.play = setInterval(function(){
                _this.a++;
                if(_this.a<_this.d){
                    if(_this.a==_this.d-1){_this.a=-1}
                    _this.btn.find('li').eq(_this.a).addClass(_this.change).siblings().removeClass(_this.change);
                    _this.list.eq(_this.a).css(comm.blind_event(_this.ani,0.8,0)).show().siblings().hide();
                }
            },_this.timer);
        },
        prev:function(){
            var _this=this;
            _this.prev1.click(function(){
                clearInterval(_this.play);
                _this.a--;
                if(_this.a==-1){_this.a=_this.d-1}
                $('.m-wap .number .show .fen').text(_this.a+1);
                _this.btn.find('li').eq(_this.a).addClass(_this.change).siblings().removeClass(_this.change);
                _this.list.eq(_this.a).css(comm.blind_event(_this.ani,0.8,0)).show().siblings().hide();
            });
        },
        next:function(){
            var _this=this;
            _this.next1.click(function(){
                clearInterval(_this.play);
                _this.a++;
                if(_this.a==_this.d){_this.a=0}
                $('.m-wap .number .show .fen').text(_this.a+1);
                _this.btn.find('li').eq(_this.a).addClass(_this.change).siblings().removeClass(_this.change);
                _this.list.eq(_this.a).css(comm.blind_event(_this.ani,0.8,0)).show().siblings().hide();
            });
        }
    };
调用方法很简单,需要依赖animate来自己添加什么显示效果 也可以自己编辑关键帧
此方法只适合pc端并且不能获取index来判断是第几张,适合宣传页面用 var zhanglei = new Switcher({ box: $('.banner'),//最外层div banner: $('.banner .content'),//包裹图片的ul timer: 2500,//切换图片时间 prev:$('.banner').find('.prev'),//前进 next:$('.banner').find('.next'),//后退 ani:'fadeIn' });

  

自己随意写了个简单的依赖jquery的轮播图的更多相关文章

  1. 用jQuery实现轮播图效果,js中的排他思想

    ---恢复内容开始--- jQuery实现轮播图不用单独加载. 思路: a. 通过$("#id名");选择需要的一类标签,获得一个伪数组 b.由于是伪数组的原因,而对数组的处理最多 ...

  2. 用js和jQuery做轮播图

    Javascript或jQuery做轮播图 css样式 <style> a{ text-decoration:none; } .naver{ width: 100%; position:r ...

  3. 自实现PC端jQuery版轮播图

    最近其他项目不是很忙,被安排给公司的官网项目做一个新的页面(之前没接触公司官网项目),其中有一个用到轮播图的地方,最开始想直接用swiper.js插件实现就好了,可是发现官网项目里之前都没有引入过sw ...

  4. JQuery实现轮播图及其原理

    源码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" name="vi ...

  5. Jquery无缝轮播图的制作

    轮播是html页面中比较常见的一种展现形式,也是基础,把轮播图做好,是排版中比较关键的 1.首先是轮播的html元素放置:做轮播之前,要有一个初步的认识 2.每个元素的位置怎样摆放,也是很关键的,这里 ...

  6. jquery优化轮播图2

    继续优化 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...

  7. jquery改造轮播图1

    g改造轮播图1:https://www.cnblogs.com/huanghuali/p/8677338.html <!DOCTYPE html> <html lang=" ...

  8. jQuery无缝轮播图思路详解-唯品会

    效果图如上: 需求:图片自动轮播,鼠标移上停止播放,离开恢复播放,箭头切换图片. html代码 <!--轮播图大盒子开始--> <div class="wrap" ...

  9. jQuery封装轮播图插件

    // 布局要求,必须有一个容器,图片和两个按钮,布局方式自定,小圆点样式固定 // <div class="all"> // <img src="img ...

随机推荐

  1. yii2整理

    对于yii的研究,还没有那么深刻,之所以在这种情况下写,还是考虑到了后来入门人没有中文资料,而又无可下手的尴尬境地.希望对新手和我自己多一份帮助吧.总结几个自己的经验吧.环境的配置我就不做解释了.这个 ...

  2. Charles 3.11.5 绿色特别版

    Charles 3.11.5 绿色特别版,注册码在key文本中 链接: http://pan.baidu.com/s/1hsoFcyS 密码: q6e1

  3. pandas入门

    [原]十分钟搞定pandas   本文是对pandas官方网站上<10 Minutes to pandas>的一个简单的翻译,原文在这里.这篇文章是对pandas的一个简单的介绍,详细的介 ...

  4. PHP上传大文件 分割文件上传

    最近遇到这么个情况,需要将一些大的文件上传到服务器,我现在拥有的权限是只能在一个网页版的文件管理系统来进行操作,可以解压,可以压缩,当然也可以用它来在线编辑.php文件. 文件有40M左右,但是服务器 ...

  5. Redis 数据结构使用场景

    转自http://get.ftqq.com/523.get 一.redis 数据结构使用场景 原来看过 redisbook 这本书,对 redis 的基本功能都已经熟悉了,从上周开始看 redis 的 ...

  6. 项目管理软件之易度1.5,禅道2.0,redmine1.2(附redmine1.2的安装)

    http://www.cnblogs.com/ljzforever/archive/2011/06/29/2093786.html 公司最近准备分出一套人马去客户那里做驻场研发,这就涉及到代码库的统一 ...

  7. Flex布局总结

    2009年,W3C提出了一种新的方案----Flex布局,可以简便.完整.响应式地实现各种页面布局.目前,它已经得到了所有浏览器的支持,这意味着,现在就能很安全地使用这项功能.lex布局将成为未来布局 ...

  8. ant安装(linux)

    1.下载 下载地址:http://ant.apache.org/bindownload.cgi 下载apache-ant-1.9.7-bin.tar.gz(当前最新版本),将该下载包拷贝到/data/ ...

  9. Spring day01笔记

    struts:web层,比较简单(ValueStack值栈,拦截器) hibernate:dao层,知识点杂 spring:service层,重要,讲多少用多少 --> [了解]   sprin ...

  10. nuint笔记

    注意:单元测试中,Case 与 Case 之间不能有任何关系 测试方法不能有返回值,不能有参数,测试方法必须声明为 public [TestFixture] //声明测试类 [SetUp] //建立, ...