jquery實(shí)現(xiàn)簡(jiǎn)單的banner輪播效果【實(shí)例】
朋友給我看了一個(gè)輪播效果,把js下載一看,丫丫的一個(gè)這么簡(jiǎn)單的效果,這么的就能寫(xiě)個(gè)幾百行的,嚴(yán)重影響瀏覽器加載速度嘛,以為人家寬帶流量不要錢玩的哦。。無(wú)奈之下給他寫(xiě)了個(gè)簡(jiǎn)單的,把所有代碼放上去都沒(méi)有超過(guò)70行,還有圓角的那個(gè)CSS,不是每個(gè)瀏覽器都是圓角的,不過(guò)不影響美觀,嘻嘻。
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>無(wú)標(biāo)題頁(yè)</title> <script src="js/jquery-2.1.4.js" type="text/javascript"></script> <style type="text/css"> .clear{overflow:hidden; clear:both; width:0px; height:0px; } .imgbox{width:640px; margin:0 auto; text-align:center; } ul{padding:0px; margin:0px;} ul li{float:left; list-style:none; } ul li.select{display:block;} .imgnum span{border-radius:10px; font:normal normal bold 12px/15px 微軟雅黑; color:#FFF; margin-left:5px; padding:3px 6px 3px 6px; background-color:#F90; cursor:pointer;} .imgnum span.onselect{background-color:#F00;} .imgnum{text-align:center; float:right; margin:-30px 30px; position:relative;} </style> </head> <body> <div class="imgbox"> <ul id="banner_img"> <li><img src="images/banner1.jpg"/></li> <li><img src="images/banner2.jpg"/></li> <li><img src="images/banner3.jpg"/></li> <li><img src="images/banner4.jpg"/></li> <li><img src="images/banner5.jpg"/></li> </ul> <div class="clear"></div> <div class="imgnum"> <span class="onselect">1</span> <span>2</span> <span>3</span> <span>4</span> <span>5</span> </div> </div> <script type="text/javascript"> var time = ""; var index = 1; $(function () { showimg(index); //鼠標(biāo)移入移出 $(".imgnum span").hover(function () { clearTimeout(time); var icon=$(this).text(); $(".imgnum span").removeClass("onselect").eq(icon-1).addClass("onselect"); $("#banner_img li").hide().stop(true,true).eq(icon-1).fadeIn("slow"); }, function () { index=$(this).text()> 4 ? 1 :parseInt($(this).text())+1; time = setTimeout("showimg(" + index + ")", 3000); }); }); function showimg(num) { index = num; $(".imgnum span").removeClass("onselect").eq(index-1).addClass("onselect"); $("#banner_img li").hide().stop(true,true).eq(index-1).fadeIn("slow"); index = index + 1 > 5 ? 1 : index + 1; time = setTimeout("showimg(" + index + ")", 3000); } </script> </body> </html>
注意要引用 Jquery 文件,圖片我就不放上來(lái)了,自己替換掉,注意圖片長(zhǎng)寬。
效果圖如下:
以上這篇jquery實(shí)現(xiàn)簡(jiǎn)單的banner輪播效果【實(shí)例】就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
jQuery實(shí)現(xiàn)高度靈活的表單驗(yàn)證功能示例【無(wú)UI】
這篇文章主要介紹了jQuery實(shí)現(xiàn)高度靈活的表單驗(yàn)證功能,涉及jQuery正則判斷與頁(yè)面元素動(dòng)態(tài)操作相關(guān)使用技巧,需要的朋友可以參考下2020-04-04HTML5+jQuery實(shí)現(xiàn)搜索智能匹配功能
本文主要介紹了HTML5+jquery實(shí)現(xiàn)的搜索匹配效果的實(shí)例代碼。具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧2017-03-03jQuery實(shí)現(xiàn)的多張圖無(wú)縫滾動(dòng)效果【測(cè)試可用】
這篇文章主要介紹了jQuery實(shí)現(xiàn)的多張圖無(wú)縫滾動(dòng)效果,可實(shí)現(xiàn)自定義向左或向右滾動(dòng)的功能,涉及jQuery結(jié)合時(shí)間函數(shù)動(dòng)態(tài)操作頁(yè)面元素屬性的相關(guān)技巧,需要的朋友可以參考下2016-09-09jQuery中與toggleClass等價(jià)的程序段 以及未來(lái)學(xué)習(xí)的方向
昨天開(kāi)始學(xué)jQuery,js是我前端設(shè)計(jì)技術(shù)的一塊心病,一直沒(méi)有找到很好的學(xué)習(xí)辦法。最近突然開(kāi)悟,可以學(xué)jQuery呀,這個(gè)東西比較好學(xué)。2010-03-03使用jquery為table動(dòng)態(tài)添加行的實(shí)現(xiàn)代碼
最近,有需要做一個(gè)動(dòng)態(tài)的給table,添加行,用了點(diǎn)時(shí)間,算是做成了。已測(cè)試過(guò),但如果發(fā)現(xiàn)有什么bug,可以留言,歡迎拍磚。大家一起進(jìn)步。2011-03-03jquery表格內(nèi)容篩選實(shí)現(xiàn)思路及代碼
基于jquery實(shí)現(xiàn)表格內(nèi)容篩選,本文采用兩種方式實(shí)現(xiàn),感興趣的朋友可以參考下哈,希望對(duì)你學(xué)習(xí)jquery篩選有所幫助2013-04-04