实战编写jq插件轮播图
来源:互联网 发布:java 线程池实例代码 编辑:程序博客网 时间:2024/05/16 03:56
<!DOCTYPE html><html><head><meta charset="UTF-8"><title></title></head><style>*{padding: 0px;margin: 0px;list-style: none;border: none;vertical-align: middle;}.utl li img{float: left;}.utl{width: 2800px;height: 250px;position: absolute;left: 0;top: 0;}.umhext{overflow: hidden;width: 700px;height:250px;margin: 50px auto; position: relative;}.bordernone{position: absolute;bottom: 10px;left: 50%;}.bordernone i{border: 2px solid #000000;width: 15px;height: 15px;display: inline-block;border-radius: 50%;cursor: pointer;z-index: 1;margin-left: 5px;}.bordernone i.auctiy{border: 2px solid red;}</style><script src="http://code.jquery.com/jquery-2.0.0.js"></script><body><div class="umhext"><ul class="utl"><li><img src="1.png"/></li><li><img src="2.png"/></li><li><img src="1.png"/></li><li><img src="2.png"/></li></ul><span class="bordernone"></span></div><script>(function($){// 初始化数据var CarouselRest = {auctiy:"auctiy",//标签iI:"<i></i>",//标签i:"i",//类utl:".utl",//标签bordernone:".bordernone",//标签timer:1000,//时间widthUmhext:700,//img宽度widthUtl:2800,//总宽度widthBordernone:80,//iI总宽度height:250,//img高度findLi:"li",//标签Fn:"Function",//是否为函数fag:true//是否开启定时器true开启 false关闭}// 建立数据对象$.fn.Carousel = function(pm){// 如果参数就重新赋值否则就是默认var options = $.extend(true, CarouselRest, pm);var _self = $(this);//初始化索引var index = 0;return _self.each(function(){var len = _self.find(CarouselRest.findLi);//计算出所有的小圆圈for (var i = 0 ; i<len.length ; i++) {_self.find(CarouselRest.bordernone).append(CarouselRest.iI);}_self.find(CarouselRest.i).eq(0).addClass(CarouselRest.auctiy);//小圆圈居中_self.find(CarouselRest.bordernone).css({"left":"50%","marginLeft":-CarouselRest.widthBordernone/2})//小圆圈事件操作_self.find(CarouselRest.i).on("click",function(){index = $(this).index();view(index);})//图片自动事件function auto(){index++;if(index>=len.length){index = 0;}view(index);}//在次进行封装function view(index){_self.find(CarouselRest.i).eq(index).addClass(CarouselRest.auctiy).siblings(CarouselRest.i).removeClass(CarouselRest.auctiy);_self.find(CarouselRest.utl).stop().animate({left:-CarouselRest.widthUmhext*index},230)}//开启定时器var stop=nullif(CarouselRest.fag){stop = setInterval(auto,CarouselRest.timer);_self.hover(function(){clearTimeout(stop)},function(){stop = setInterval(auto,CarouselRest.timer);})}})}})(jQuery)$(".umhext").Carousel({auctiy:"auctiy",//类iI:"<i></i>",//标签i:"i",//类utl:".utl",//标签bordernone:".bordernone",//类timer:1500,//时间widthUmhext:700,//img宽度widthUtl:2800,//总宽度widthBordernone:80,//iI总宽度height:250,//img高度findLi:"li",//标签Fn:"Function",//是否为函数fag:true//是否开启定时器true开启 false关闭});</script></body></html>
0 0
- 实战编写jq插件轮播图
- jq 插件编写 待
- jQ 编写插件
- jq编写轮播插件
- 【前端】jq插件的编写
- jq插件的编写方法(自定义jq插件)
- [jq] 最终确定的jq插件结构编写
- 2017/8/13 jq编写插件方法
- JS+JQ轮播图插件
- JQ插件
- jq插件
- 编写Gradle插件配合ASM框架实战
- jq插件的编写中(jquery.extend、jquery.fn与jquery.fn.extend的使用区别)
- JQ滚动插件
- JQ 上传插件
- jq小插件tiptip
- jq遮罩层插件
- JQ 倒计时插件
- 水平分库分表的关键步骤以及可能遇到的问题
- Java 中的标识符
- AUX的清洁模式怎么使用?
- SQLite数据库存储之查询数据
- 面试 需要警惕三个问题
- 实战编写jq插件轮播图
- JVM介绍
- 分库分表的几种常见形式以及可能遇到的难题
- android studio恢复误删文件
- CocoaPods导入的库其头文件导入的方法
- Win10在python3.3下通过源码安装cx_Freeze
- Node.js和PHP运行机制对比
- se78 上传图片(logo使用)/SWM0上传文件
- 微信小程序之TabBar的使用