jQuery簡單實現(xiàn)banner圖片切換
主要運用了定時器的原理,bind,trigger應(yīng)用等
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>banner切換實現(xiàn)</title>
<style type="text/css">
/*
* @description: banner切換樣式
* @author: lanfeng(beryl)
* @time:2013-02-26
*/
/* reset*/
*{ margin: 0; padding: 0;}
body{font:12px/1.5 Tahoma,'\5B8B\4F53',arial,Tahoma,helvetica,sans-serif; color:#333333;background-color:#ffffff;position:relative; }
h1,h2,h3,h4,h5,h6{font-size:100%}
address,em{font-style:normal;}
code,kbd,pre,samp{font-family:courier new,courier,monospace;}
ul,ol{list-style:none outside none;}
fieldset,img{border:0;}
img{vertical-align:middle}
table{border-collapse:collapse;border-spacing:0;font-size:inherit;*font-size:100%;}
input,button,textarea,select{vertical-align:middle;font:100% Helvetica,Arial,sans-serif; color:inherit}
.clearfix:after{content:'.';display:block;height:0;clear:both;visibility:hidden;}
.clearfix{*zoom:1;}
.clear{font-size:0;line-height:0;height:0;clear:both;visibility:hidden;overflow:hidden;}
.d-ftab{ width:510px; height: 180px;position: relative; margin: 100px auto;}
.d-fShow ul li{ float: left; width: 510px; height: 180px;}
.d-fShow{ width: 510px; height: 180px; overflow: hidden;}
.d-fShow img{ width: 510px; height: 180px; float: left;}
.d-fs-control{ position: absolute; width:510px; position: absolute; left: 0; bottom: 0; height: 25px; line-height: 25px;
background: rgba(0,0,0,0.4);
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#66000000',
EndColorStr='#66000000') ; }
:root .d-fs-control{filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#66000000'
,EndColorStr='#66000000')\9 ;}
.d-fs-control ul{ position: absolute; bottom:3px; right: 5px; height: 16px;}
.d-fs-control ul li{width:16px;height:16px; background:#777675;border-radius: 2px 2px 2px 2px; float:left;margin-left:5px;
color:#dcdcdc;text-align:center;font-weight:700;cursor:pointer;line-height:16px;filter: alpha(opacity=70); opacity: 0.7;}
.d-fs-control ul li:hover,.d-fs-control ul li.select{background:#ffffff;color:#ff6700;}
</style>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
var wrap =$('.d-ftab');
var imgs = wrap.find('.d-fShow ul >li');
var len=imgs.length ;
var tabTime=100;
var outTime=4000;
var select='select';
var num =0 ;
var interval;
var type = 'click';
var btns=wrap.find('.d-fs-control ul>li');
btns.bind(type,function(){
var _this=$(this);
_this.addClass('select').siblings ().removeClass('select');
num=_this.prevAll().length;
imgs.stop().eq(num).fadeTo(tabTime,1) ;
imgs.not(':eq('+num+')').filter(':visible').fadeOut(tabTime) ;
return false;
}).eq(num).trigger(type);
var interFunc=function(){
num=(num+1)%len;
btns.eq(num).triggerHandler(type);
}
wrap.bind('mouseover',function(){
clearInterval(interval);
}).bind('mouseout',function(){
interval=setInterval(interFunc,outTime)
})
})
</script>
</head>
<body>
<div class="d-ftab">
<div class="d-fShow">
<ul>
<li>
<a href="#"><img alt="" src=" images/1.jpg"/>
</a>
</li>
<li >
<a href="#"><img alt="" src="images/2.png">
</a>
</li>
<li>
<a href="#"><img alt="" src="images/3.jpg">
</a>
</li>
<li>
<a href=""><img alt="" src="images/4.jpg">
</a>
</li>
<li>
<a href="#"><img alt="" src="images/5.jpg">
</a>
</li>
</ul>
</div>
<div class="d-fs-control">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li class="select">5</li>
</ul>
</div>
</div>
</body>
</html>
效果如下圖:

相關(guān)文章
基于jquery實現(xiàn)可定制的web在線富文本編輯器附源碼下載
UEditor的功能非常強大,官方已配備了php,asp,asp.net,java等語言的上傳程序,拿來就可以使用,當(dāng)然ueditor更具有功能插件接口,很輕松地添加自己定義功能到編輯器中,方便項目的不同需求2015-11-11vue登錄頁面cookie的使用及頁面跳轉(zhuǎn)代碼
這篇文章主要介紹了vue登錄頁面cookie的使用及頁面跳轉(zhuǎn)代碼功能,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-07-07基于CSS3和jQuery實現(xiàn)跟隨鼠標(biāo)方位的Hover特效
這篇文章主要介紹了基于CSS3和jQuery實現(xiàn)跟隨鼠標(biāo)方位的Hover特效的相關(guān)資料,需要的朋友可以參考下2016-07-07jquery 禁止鼠標(biāo)右鍵并監(jiān)聽右鍵事件
本篇文章主要介紹了jquery禁止鼠標(biāo)右鍵并監(jiān)聽右鍵事件的相關(guān)知識。具有很好的參考價值。下面跟著小編一起來看下吧2017-04-04jquery簡單實現(xiàn)網(wǎng)頁層的展開與收縮效果
這篇文章主要介紹了jquery簡單實現(xiàn)網(wǎng)頁層的展開與收縮效果的方法,涉及jquery中toggle結(jié)合animate方法操作頁面元素屬性的相關(guān)技巧,非常簡單實用,需要的朋友可以參考下2015-08-08jQuery EasyUI Pagination實現(xiàn)分頁的常用方法
這篇文章主要為大家詳細介紹了jQuery EasyUI Pagination實現(xiàn)分頁的常用方法,感興趣的朋友可以參考一下2016-05-05