基于jquery實(shí)現(xiàn)圖片廣告輪換效果代碼

實(shí)現(xiàn)代碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>hotmarquee</title>
<style type="text/css">
*
{
margin: 0;
padding: 0;
}
body
{
font: 12px;
padding-top: 50px;
padding-right: 200px;
padding-bottom: 100px;
padding-left: 200px;
}
ul
{
list-style: none;
}
img
{
padding: 2px;
border: 1px solid #eee;
}
a
{
outline: none;
}
#imgs
{
width: 410px;
margin-right: auto;
margin-left: auto;
}
.top, .btm
{
background: url(../images/sprite.gif) no-repeat;
overflow: hidden;
}
.top
{
background-position: 0 0;
height: 5px;
}
.btm
{
height: 7px;
}
.mid
{
width: 400px;
padding: 5px 7px 0;
border: 1px solid #999;
}
.mid ul
{
width: 400px;
height: 600px;
background: #fff;
position: relative;
overflow: hidden;
}
.mid ul li
{
width: 400px;
height: 600px;
position: absolute;
left: 490px;
top: 0;
}
.mid ul li.first
{
left: 0;
}
#img_list
{
width: 486px;
height: 20px;
padding-top: 5px;
overflow: hidden;
height: 1%;
}
#img_list a
{
display: block;
width: 14px;
height: 14px;
text-indent: -9999px;
float: left;
margin-right: 5px;
background: url(../images/sprite.gif) no-repeat 0 -13px;
}
#img_list a:hover, #img_list a.active
{
background-position: -14px -13px;
}
</style>
<script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
var curr = 0, next = 0, count = 0;
$(document).ready(function () {
// 記錄圖片的數(shù)量
count = $('#img_list a').size();
t = setInterval('imgPlay()', 3000);
// 鼠標(biāo)移動(dòng)到圖片或?qū)Ш缴贤V共シ牛崎_后恢復(fù)播放
$('#imgs li, #img_list a').hover(function () {
clearInterval(t);
}, function () {
t = setInterval('imgPlay()', 3000);
});
//點(diǎn)擊導(dǎo)航播放到相應(yīng)的圖片
$('#img_list a').click(function () {
// index()函數(shù)返回當(dāng)前導(dǎo)航的下標(biāo)
var index = $('#img_list a').index(this);
if (curr != index) {
play(index);
curr = index;
};
return false;
});
});
// 播放圖片的函數(shù)
var imgPlay = function () {
next = curr + 1;
// 若當(dāng)前圖片播放到最后一張,這設(shè)置下一張要播放的圖片為第一張圖片的下標(biāo)
if (curr == count - 1) next = 0;
play(next);
curr++;
// 在當(dāng)前圖片的下標(biāo)加1后,若值大于最后一張圖片的下標(biāo),則設(shè)置下一輪其實(shí)播放的圖片下標(biāo)為第一張圖片的下標(biāo),而next永遠(yuǎn)比curr大1
if (curr > count - 1) { curr = 0; next = curr + 1; }
};
// 控制播放效果的函數(shù)
var play = function (next) {
// 當(dāng)前的圖片滑到左邊-500px,完成后返回到右邊490px
// 下一張圖片滑到0px處,完成后導(dǎo)航的焦點(diǎn)切換到下一個(gè)點(diǎn)上
$('#imgs li').eq(curr).css({ 'opacity': '0.5' }).animate({ 'left': '-500px', 'opacity': '1' }, 'slow', function () {
$(this).css({ 'left': '490px' });
}).end()
.eq(next).animate({ 'left': '0px', 'opacity': '1' }, 'slow', function () {
$('#img_list a').siblings('a').removeClass('active').end().eq(next).addClass('active');
});
};
</script>
</head>
<body>
<div id="imgs">
<div class="mid">
<ul>
<li class="first"><a
target="_blank">
<img src="http://meinv.vs2010.com/DownLoad/2011-7-6/e9c17b8d52e14757b03729fe57dac21f.jpg"
alt="1" /></a></li>
<li><a target="_blank">
<img src="http://meinv.vs2010.com/DownLoad/2011-7-2/2aaaba4b512c4af9ad335d962ea1b00e.jpg"
alt="2" /></a></li>
<li><a target="_blank">
<img src="http://meinv.vs2010.com/DownLoad/2011-7-1/622f65f85622417f8c19a47545265c41.jpg"
alt="3" /></a></li>
<li><a target="_blank">
<img src="http://meinv.vs2010.com/DownLoad/2011-6-25/81575b5f42ff417e85c13f9a77054f8c.jpg"
alt="4" /></a></li>
</ul>
<div id="img_list">
<a href="#1" class="active">1</a> <a href="#2">2</a> <a href="#3">3</a> <a href="#4">
4</a>
</div>
</div>
</div>
</body>
</html>
- jquery實(shí)現(xiàn)兩邊飄浮可關(guān)閉的對(duì)聯(lián)廣告
- jQuery網(wǎng)頁右側(cè)廣告跟隨滾動(dòng)代碼分享
- jquery實(shí)現(xiàn)可關(guān)閉的倒計(jì)時(shí)廣告特效代碼
- jquery實(shí)現(xiàn)滑屏大圖定時(shí)收縮為小banner圖片的廣告代碼
- jquery右下角自動(dòng)彈出可關(guān)閉的廣告層
- jQuery實(shí)現(xiàn)首頁頂部可伸縮廣告特效代碼
- jquery實(shí)現(xiàn)對(duì)聯(lián)廣告的方法
- 基于jquery實(shí)現(xiàn)的定時(shí)顯示與隱藏div廣告的實(shí)現(xiàn)代碼
- jQuery 浮動(dòng)廣告實(shí)現(xiàn)代碼
- jQuery實(shí)現(xiàn)頁面頂部下拉廣告
相關(guān)文章
jQuery EasyUI之驗(yàn)證框validatebox實(shí)例詳解
本文通過實(shí)例代碼給大家講解了jQuery EasyUI之驗(yàn)證框validatebox知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的的朋友參考下吧2017-04-04jquery插件制作 表單驗(yàn)證實(shí)現(xiàn)代碼
今天的內(nèi)容是關(guān)于表單驗(yàn)證插件的制作。表單驗(yàn)證控件實(shí)現(xiàn)的主要功能是,當(dāng)表單提交的時(shí)候檢查必填項(xiàng)是否正確填寫,同時(shí)根據(jù)需要驗(yàn)證輸入信息是否符合規(guī)范2012-08-08jquery.Jwin.js 基于jquery的彈出層插件代碼
測(cè)試頁面需要引用jquery的js文件 插件文件jquery.Jwin.js jquery.Jwin插件的使用參數(shù)都有詳細(xì)說明2012-05-05jQuery得到多個(gè)值只能用取Class ,不能用取ID的方法
下面小編就為大家?guī)硪黄猨Query得到多個(gè)值只能用取Class ,不能用取ID的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-12-12淺析jQuery Ajax請(qǐng)求參數(shù)和返回?cái)?shù)據(jù)的處理
這篇文章主要介紹了淺析jQuery Ajax請(qǐng)求參數(shù)和返回?cái)?shù)據(jù)的處理的相關(guān)資料,需要的朋友可以參考下2016-02-02html+jQuery實(shí)現(xiàn)拖動(dòng)滑塊圖片拼圖驗(yàn)證碼插件【移動(dòng)端適用】
這篇文章主要介紹了html+jQuery實(shí)現(xiàn)拖動(dòng)滑塊圖片拼圖驗(yàn)證碼插件,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-09-09jquery實(shí)現(xiàn)不同大小瀏覽器使用不同的css樣式表的方法
這篇文章主要介紹了jquery實(shí)現(xiàn)不同大小瀏覽器使用不同的css樣式表的方法,需要的朋友可以參考下2014-04-04jquery動(dòng)態(tài)添加帶有樣式的HTML標(biāo)簽元素方法
下面小編就為大家分享一篇jquery動(dòng)態(tài)添加帶有樣式的HTML標(biāo)簽元素方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-02-02jQuery插件擴(kuò)展extend的簡(jiǎn)單實(shí)現(xiàn)原理
下面小編就為大家?guī)硪黄猨Query插件擴(kuò)展extend的簡(jiǎn)單實(shí)現(xiàn)原理。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-06