jQuery实现一个简单的轮播图

前端之家收集整理的这篇文章主要介绍了jQuery实现一个简单的轮播图前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

HTML代码

轮播图练习@H_<a href="https://www.jb51.cc/tag/502/" target="_blank" class="keywords">502</a>_8@ <link rel="stylesheet" href="css/css.css" rel="external <a href="https://www.jb51.cc/tag/nofollow/" target="_blank" class="keywords">nofollow</a>" type="text/css"/> </head> <body> <ul class="back"> <!-- 背景图片 -->   <li class="l1"></li>   <li class="l2"></li>   <li class="l3"></li>   <li class="l4"></li>   <li class="l5"></li> </ul> <ul class="point"> <!-- 控制按钮 -->   <li class="active"></li>   <li></li>   <li></li>   <li></li>   <li></li> </ul> <div class="btn"> <!-- 左右控制按钮 -->   <span class="prev"></span>   <span class="next"></span> </div> </body> <script src="js/jquery-1.7.2.js"></script> <script src="js/jq.js"></script> </html></pre> </div> <p><h3>css<a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>:</h3></p> <div class="jb51code"> <pre class="brush:css;"> *{margin:0; padding: 0;} ul li{list-style: none;} .back{height: 400px; overflow: hidden; margin-top:100px;} .back li{width: 100%; height: 400px; margin:0 auto;} .back li.l1{background: red;} .back li.l2{background: yellow;} .back li.l3{background: blue;} .back li.l4{background: black;} .back li.l5{background: green;} .point{text-align: center; margin-top: -30px;} .point li{ width: 20px; height: 20px; border:2px solid #fff; border-radius: 10px; <a href="https://www.jb51.cc/tag/Box/" target="_blank" class="keywords">Box</a>-sizing:border-<a href="https://www.jb51.cc/tag/Box/" target="_blank" class="keywords">Box</a>; display: inline-block;} .point li.active{background: #fff;} .btn{ position: relative;} .btn span{ display: inline-block; vertical-align: top; width: 100px; height: 100px; background: rgba(0,.5); position: absolute; top:-235px; cursor: pointer;} .btn .prev{left: 0} .btn .next{ right: 0;} </pre> </div> <p><h3>js<a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>:</h3></p> <div class="jb51code"> <pre class="brush:js;"> $(function(){   function banner(a,b,c,d,e){ // a是背景图,b是active,c是背景对应按钮,d是<a href="https://www.jb51.cc/tag/shangyiye/" target="_blank" class="keywords">上一页</a>,e是<a href="https://www.jb51.cc/tag/xiayiye/" target="_blank" class="keywords">下一页</a>     index=0;     len=$(a).length-1;     function teb(index){       $(c).eq(index).addClass(b).siblings('').removeClass(b);       $(a).eq(index).fadeIn(300).addClass('curr').siblings('').fadeOut(300).removeClass('curr');     };     $(c).click(function(){       index=$(this).index();       teb(index);     });     $(d).click(function(){       index--;       if(index<0){         index=len;       };       teb(index);     });     $(e).click(function(){       index++;       if(index>len){         index=0;       };       teb(index);     });     function timeRun(){       time=setInterval(function(){         index++;         if(index>len){           index=0;         };         teb(index);       },3000);     };     timeRun();   };   banner('.back>li','active','.point>li','.prev','.next'); }); </pre> </div> <p>以上就是本文的全部<a href="https://www.jb51.cc/tag/neirong/" target="_blank" class="keywords">内容</a>,希望本文的<a href="https://www.jb51.cc/tag/neirong/" target="_blank" class="keywords">内容</a>对大家的学习或者工作能带来一定的帮助,同时也希望多多<a href="https://www.jb51.cc/tag/zhichi/" target="_blank" class="keywords">支持</a>编程之家!</p><i class="glyphicon glyphicon-link"></i> 原文链接:https://www.f2er.com/jquery/41511.html</div> <div class="topcard-tags"><a href="https://www.f2er.com/tag/jqueryp/" class="tag_link" target="_blank">jquery</a><a href="https://www.f2er.com/tag/jqueryshixianlunbo/" class="tag_link" target="_blank">jquery实现轮播</a><a href="https://www.f2er.com/tag/jiandanlunbotu/" class="tag_link" target="_blank">简单轮播图</a><a href="https://www.f2er.com/tag/lunbo/" class="tag_link" target="_blank">轮播</a></div> <ul class="list-group"> <li class="list-group-item"><a href="https://www.f2er.com/jquery/41539.html" title="jQuery仿IOS弹出框插件">上一篇:jQuery仿IOS弹出框插件</a><a href="https://www.f2er.com/jquery/41486.html" title="Bootstrap jquery.twbsPagination.js动态页码分页实例代码" class="text-muted pull-right">下一篇:Bootstrap jquery.twbsPagination.</a> </li> </ul> </div> </div> </div> <!-- row end --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-4605373693034661" data-ad-slot="9144498553"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script></div> </div> </div> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <div class="title"><h1>猜你在找的jQuery相关文章</h1></div> <div class="list_con"> <a href="https://www.f2er.com/jquery/994522.html" title="《锋利的jQuery》笔记:插件的使用和写法"><div class="title">《锋利的jQuery》笔记:插件的使用和写法</div> <div class="summary">jQuery插件的种类 1、封装对象方法 这种插件是将对象方法封装起来,用于对通过选择器获取的...</div> <time class="summary">作者:前端之家 时间:2020-12-28</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/jquery/994521.html" title="jQuery插件开发入门"><div class="title">jQuery插件开发入门</div> <div class="summary">扩展jQuery插件和方法的作用是非常强大的,它可以节省大量开发时间。 入门 编写一个jQuery...</div> <time class="summary">作者:前端之家 时间:2020-12-28</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/jquery/994520.html" title="jquery.roundabout.js实现3D图片层叠旋转木马切换"><img class="lazy" src="https://www.f2er.com/images/np.jpg" data-original="https://www.f2er.com/res/2020/12-28/08/dffb45ce0cf3e295e280f6fb71053099.png" title="" width="160" height="90" style="float:right;margin-left:30px;display:none;" /><div class="title">jquery.roundabout.js实现3D图片层叠旋转木马切换</div> <div class="summary">最近项目中需要实现3D图片层叠旋转木马切换的效果,于是用到了jquery.roundabout.js。 兼容...</div> <time class="summary">作者:前端之家 时间:2020-12-28</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/jquery/994519.html" title="jQuery效果之jQuery实现图片的依次加载图片"><div class="title">jQuery效果之jQuery实现图片的依次加载图片</div> <div class="summary">css代码: js代码:</div> <time class="summary">作者:前端之家 时间:2020-12-28</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/jquery/994518.html" title="jQuery之deferred对象详解"><div class="title">jQuery之deferred对象详解</div> <div class="summary">一、什么是deferred对象? 开发网站的过程中,我们经常遇到某些耗时很长的javascript操作。...</div> <time class="summary">作者:前端之家 时间:2020-12-28</time> </a> </div> <div style="border-bottom: 1px solid #f4f4f4;margin-top:20px;"> <ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-fr-2o+fp-dx-wx" data-ad-client="ca-pub-4605373693034661" data-ad-slot="4561116489"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div><div class="list_con"> <a href="https://www.f2er.com/jquery/994516.html" title="jQuery插件开发进阶"><img class="lazy" src="https://www.f2er.com/images/np.jpg" data-original="https://www.f2er.com/res/2020/12-28/08/cf0a3ddd7df38e4fd13375e560fd833a.png" title="" width="160" height="90" style="float:right;margin-left:30px;display:none;" /><div class="title">jQuery插件开发进阶</div> <div class="summary">jQuery插件开发模式 软件开发过程中是需要一定的设计模式来指导开发的,有了模式,我们就能...</div> <time class="summary">作者:前端之家 时间:2020-12-28</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/jquery/994515.html" title="jQuery 实现邮箱输入自动提示功能:(一)"><img class="lazy" src="https://www.f2er.com/images/np.jpg" data-original="https://www.f2er.com/res/2020/12-28/08/495a5225e66f1d897f5b3ccf684c9dd1.png" title="" width="160" height="90" style="float:right;margin-left:30px;display:none;" /><div class="title">jQuery 实现邮箱输入自动提示功能:(一)</div> <div class="summary">记得去年做某个项目的时候,用到了邮箱输入自动提示功能,于是网上搜了一下,发现了这个写...</div> <time class="summary">作者:前端之家 时间:2020-12-28</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/jquery/994514.html" title="jQuery插件之上传文件ajaxfileupload.js源码与使用"><div class="title">jQuery插件之上传文件ajaxfileupload.js源码与使用</div> <div class="summary">在网页应用中,一般会用到上传文件或者图片什么的到服务器,那么可以用ajaxfileupload.js,...</div> <time class="summary">作者:前端之家 时间:2020-12-28</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/jquery/994513.html" title="jQuery效果之封装一个文章图片弹出放大效果"><div class="title">jQuery效果之封装一个文章图片弹出放大效果</div> <div class="summary">首先先搭写一个基本的格式: 然后用自调用匿名函数包裹你的代码,将系统变量以变量形式传递...</div> <time class="summary">作者:前端之家 时间:2020-12-28</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/jquery/994512.html" title="《从零开始学习jQuery》:用jQuery操作元素的属性与样式"><img class="lazy" src="https://www.f2er.com/images/np.jpg" data-original="https://www.f2er.com/res/2020/12-28/08/c7ddac708bcf22aec7f66ac24509d2ca.png" title="" width="160" height="90" style="float:right;margin-left:30px;display:none;" /><div class="title">《从零开始学习jQuery》:用jQuery操作元素的属性与样式</div> <div class="summary">元素属性和Dom属性简介 对于下面这样一个标签元素: 我们通常将id,src,alt,class称为属性,也...</div> <time class="summary">作者:前端之家 时间:2020-12-28</time> </a> </div> <div style="border-bottom: 1px solid #f4f4f4;margin-top:20px;"> <ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-fr-2o+fp-dx-wx" data-ad-client="ca-pub-4605373693034661" data-ad-slot="4561116489"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div></div> </div> </div> </div> <!-- left end--> <!-- right --> <div class="col-sm-12 col-md-12 col-lg-3"> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <label class="main-content-label ">编程分类</label> <div class="cate mt-20"><a href="https://www.f2er.com/html/" title="HTML">HTML</a><a href="https://www.f2er.com/html5/" title="HTML5">HTML5</a><a href="https://www.f2er.com/js/" title="JavaScript">JavaScript</a><a href="https://www.f2er.com/css/" title="CSS">CSS</a><a href="https://www.f2er.com/jquery/" title="jQuery">jQuery</a><a href="https://www.f2er.com/bootstrap/" title="Bootstrap">Bootstrap</a><a href="https://www.f2er.com/angularjs/" title="Angularjs">Angularjs</a><a href="https://www.f2er.com/typescript/" title="TypeScript">TypeScript</a><a href="https://www.f2er.com/vue/" title="Vue">Vue</a><a href="https://www.f2er.com/dojo/" title="Dojo">Dojo</a><a href="https://www.f2er.com/json/" title="Json">Json</a><a href="https://www.f2er.com/electron/" title="Electron">Electron</a><a href="https://www.f2er.com/nodejs/" title="Node.js">Node.js</a><a href="https://www.f2er.com/extjs/" title="extjs">extjs</a><a href="https://www.f2er.com/express/" title="Express ">Express </a><a href="https://www.f2er.com/xml/" title="XML">XML</a><a href="https://www.f2er.com/es6/" title="ES6">ES6</a><a href="https://www.f2er.com/ajax/" title="Ajax">Ajax</a><a href="https://www.f2er.com/flash/" title="Flash">Flash</a><a href="https://www.f2er.com/unity/" title="Unity">Unity</a><a href="https://www.f2er.com/react/" title="React">React</a><a href="https://www.f2er.com/flex/" title="Flex">Flex</a><a href="https://www.f2er.com/antdesign/" title="Ant Design">Ant Design</a><a href="https://www.f2er.com/webfrontend/" title="Web前端">Web前端</a><a href="https://www.f2er.com/weapp/" title="微信小程序">微信小程序</a><a href="https://www.f2er.com/wxmp/" title="微信公众号">微信公众号</a><div class="clearfix"></div> </div> </div> </div> </div> <!-- row end --> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <!-- f2er-rightads --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-4605373693034661" data-ad-slot="7756441254" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> <!-- row end --> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <label class="main-content-label ">最新文章</label> <ul class="n-list"><li><a href="https://www.f2er.com/jquery/994522.html" title="《锋利的jQuery》笔记:插件的使用和写法" target="_blank">• 《锋利的jQuery》笔记:插</a></li> <li><a href="https://www.f2er.com/jquery/994521.html" title="jQuery插件开发入门" target="_blank">• jQuery插件开发入门</a></li> <li><a href="https://www.f2er.com/jquery/994520.html" title="jquery.roundabout.js实现3D图片层叠旋转木马切换" target="_blank">• jquery.roundabout.js实现</a></li> <li><a href="https://www.f2er.com/jquery/994519.html" title="jQuery效果之jQuery实现图片的依次加载图片" target="_blank">• jQuery效果之jQuery实现图</a></li> <li><a href="https://www.f2er.com/jquery/994518.html" title="jQuery之deferred对象详解" target="_blank">• jQuery之deferred对象详解</a></li> <li><a href="https://www.f2er.com/jquery/994517.html" title="jQuery 对AMD的支持(Require.js中如何使用jQuery)" target="_blank">• jQuery 对AMD的支持(Requ</a></li> <li><a href="https://www.f2er.com/jquery/994516.html" title="jQuery插件开发进阶" target="_blank">• jQuery插件开发进阶</a></li> <li><a href="https://www.f2er.com/jquery/994515.html" title="jQuery 实现邮箱输入自动提示功能:(一)" target="_blank">• jQuery 实现邮箱输入自动提</a></li> <li><a href="https://www.f2er.com/jquery/994514.html" title="jQuery插件之上传文件ajaxfileupload.js源码与使用" target="_blank">• jQuery插件之上传文件ajax</a></li> <li><a href="https://www.f2er.com/jquery/994513.html" title="jQuery效果之封装一个文章图片弹出放大效果" target="_blank">• jQuery效果之封装一个文章</a></li> </ul> </div> </div> </div> <!-- row end --> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <label class="main-content-label ">热门标签 <span class="pull-right tx-12"> <a href="https://www.f2er.com/all" target="_blank">更多 ►</a></span> </label> <div class="topcard-tags"><a href="https://www.f2er.com/tag/guanbiyangao/" title="关闭广告" target="_blank">关闭广告</a><a href="https://www.f2er.com/tag/danduheaders/" title="单独headers" target="_blank">单独headers</a><a href="https://www.f2er.com/tag/fengzhuangdaima/" title="封装代码" target="_blank">封装代码</a><a href="https://www.f2er.com/tag/tishicuowu/" title="提示错误" target="_blank">提示错误</a><a href="https://www.f2er.com/tag/zhengshuzhengze/" title="整数正则" target="_blank">整数正则</a><a href="https://www.f2er.com/tag/fei0kaitou/" title="非0开头" target="_blank">非0开头</a><a href="https://www.f2er.com/tag/tiaoye/" title="跳页" target="_blank">跳页</a><a href="https://www.f2er.com/tag/chuyema/" title="出页码" target="_blank">出页码</a><a href="https://www.f2er.com/tag/antdtable/" title="antd table" target="_blank">antd table</a><a href="https://www.f2er.com/tag/tishiURLweizhuce/" title="提示URL未注册" target="_blank">提示URL未注册</a><a href="https://www.f2er.com/tag/gongzhonghaozhifu/" title="公众号支付" target="_blank">公众号支付</a><a href="https://www.f2er.com/tag/vuehashmoshi/" title="vue hash模式" target="_blank">vue hash模式</a><a href="https://www.f2er.com/tag/iSlider/" title="iSlider" target="_blank">iSlider</a><a href="https://www.f2er.com/tag/chepaijianpan/" title="车牌键盘" target="_blank">车牌键盘</a><a href="https://www.f2er.com/tag/xunhuantupian/" title="循环图片" target="_blank">循环图片</a><a href="https://www.f2er.com/tag/echartsshuangzhexian/" title="echarts 双折线" target="_blank">echarts 双折</a><a href="https://www.f2er.com/tag/zuoyoubuju/" title="左右布局" target="_blank">左右布局</a><a href="https://www.f2er.com/tag/DllPlugin/" title="DllPlugin" target="_blank">DllPlugin</a><a href="https://www.f2er.com/tag/duixiangchuangjian/" title="对象创建" target="_blank">对象创建</a><a href="https://www.f2er.com/tag/daziyouxi/" title="打字游戏" target="_blank">打字游戏</a><a href="https://www.f2er.com/tag/quanxuan/" title="圈选" target="_blank">圈选</a><a href="https://www.f2er.com/tag/lianglan/" title="两栏" target="_blank">两栏</a><a href="https://www.f2er.com/tag/yunhanshu/" title="云函数" target="_blank">云函数</a><a href="https://www.f2er.com/tag/mengban/" title="蒙版" target="_blank">蒙版</a><a href="https://www.f2er.com/tag/ES2020/" title="ES2020" target="_blank">ES2020</a><a href="https://www.f2er.com/tag/chuchuang/" title="橱窗" target="_blank">橱窗</a><a href="https://www.f2er.com/tag/wufenggundonglunbo/" title="无缝滚动轮播" target="_blank">无缝滚动轮播</a><a href="https://www.f2er.com/tag/sekuaipengzhuang/" title="色块碰撞" target="_blank">色块碰撞</a><a href="https://www.f2er.com/tag/zujianxiaohui/" title="组件销毁" target="_blank">组件销毁</a><a href="https://www.f2er.com/tag/wendangcaozuo/" title="文档操作" target="_blank">文档操作</a></div> </div> </div> </div> <!-- row end --> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <!-- f2er-rightads --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-4605373693034661" data-ad-slot="7756441254" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> <!-- row end --> </div> <!-- right end --> </div> </div> <footer id="footer"> <div class="container"> <div class="row hidden-xs"> <dl class="col-sm-6 site-link"> <dt>最近更新</dt><dd><a href="https://www.f2er.com/faq/884225.html" title="jQuery选择伪元素:after" target="_blank">· jQuery选择伪元素:after</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884224.html" title="JavaScript随机颜色生成器" target="_blank">· JavaScript随机颜色生成器</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884223.html" title="JavaScript指数" target="_blank">· JavaScript指数</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884222.html" title="addResourceHandlers无法解析静态资源" target="_blank">· addResourceHandlers无法解析静态资源</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884221.html" title="如何将字节数组转换为MultipartFile" target="_blank">· 如何将字节数组转换为MultipartFile</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884220.html" title="在java中如何创建一个文件并写入内容?" target="_blank">· 在java中如何创建一个文件并写入内容?</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884219.html" title="星号*在Python中是什么意思?" target="_blank">· 星号*在Python中是什么意思?</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884218.html" title="Flask框架:MVC模式" target="_blank">· Flask框架:MVC模式</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884217.html" title="在JavaScript对象数组中按ID查找对象" target="_blank">· 在JavaScript对象数组中按ID查找对象</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884216.html" title="使用Javascript / jQuery下载文件" target="_blank">· 使用Javascript / jQuery下载文件</a><span class="text-muted pull-right">10-20</span></dd> </dl> <dl class="col-sm-4 site-link"> <dt>好站推荐</dt><dd> <a href="https://www.runoob.com" title="菜鸟教程(www.runoob.com)提供了编程的基础技术教程, 介绍了HTML、CSS、Javascript、Python,Java,Ruby,C,PHP , MySQL等各种编程语言的基础知识。 同时本站中也提供了大量的在线实例,通过实例,您可以更好的学习编程。" target="_blank">菜鸟教程</a></dd><dd> <a href="https://www.jb51.cc" title="编程之家(www.jb51.cc)是成立于2017年面向全球中文开发者的技术内容分享平台。提供编程导航、编程问答、编程博文、编程百科、编程教程、编程工具、编程实例等开发者最需要的编程技术内容与开发工具支持,与你一起学习编程,相信编程改变未来!" target="_blank">编程之家</a></dd><dd> <a href="https://www.f2er.com" title="前端之家 f2er.com 前端开发人员所需学习知识手册。" target="_blank">前端之家</a></dd></dl> <dl class="col-sm-2 site-link"> <dt>商务合作</dt> <dd><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=76874919&site=qq&menu=yes">联系我们</a></dd> </dl> </div> <div class="copyright"> Copyright © 2019 前端之家. 当前版本 V7.0.16<br> <span class="ml5">前端之家 版权所有 <a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">闽ICP备13020303号-10</a></span> </div> </div> </footer> <script type="text/javascript" src="https://www.f2er.com/js/base.js"></script> </body> </html>