jQuery實現(xiàn)圖片簡單輪播功能示例
本文實例講述了jQuery實現(xiàn)圖片簡單輪播功能。分享給大家供大家參考,具體如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>www.dbjr.com.cn jQuery圖片輪播</title>
<style type="text/css">
#frame{
width:700px;
height:300px;
position:relative;
}
#img2,#img3{
display:none;
}
.box{
position:absolute;
width:50px;
height:50px;
line-height:50px;
text-align:center;
color:white;
font-family:Microsoft-Yahei;
background:grey;
}
#move1{
bottom:0;
right:100px;
}
#move2{
bottom:0;
right:50px;
}
#move3{
bottom:0;
right:0;
}
</style>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
n = 1;
interval = setInterval(
function(){
$("img").hide();
$("#img"+n).show();
$(".box").css("background","grey");
$("#move"+n).css("background","red");
n = n % 3 + 1;
}
,
2000
);
$(".box").bind("click",function() {
clearInterval(interval);
n = $(this).attr("id").slice(4);
interval = setInterval(
function(){
$("img").hide();
$("#img"+n).show();
$(".box").css("background","grey");
$("#move"+n).css("background","red");
n = n % 3 + 1;
}
,
2000
);
});
});
</script>
</head>
<body>
<div id="frame">
<div id="photos">
<img id="img1" src="images/background1.png">
<img id="img2" src="images/background2.png">
<img id="img3" src="images/background3.png">
</div>
<div class="box" id="move1">1</div>
<div class="box" id="move2">2</div>
<div class="box" id="move3">3</div>
</div>
</body>
</html>
感興趣的朋友可以使用在線HTML/CSS/JavaScript代碼運行工具:http://tools.jb51.net/code/HtmlJsRun 測試運行效果(記得替換上述圖片為網(wǎng)絡(luò)圖片)
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery圖片操作技巧大全》、《jQuery表格(table)操作技巧匯總》、《jQuery切換特效與技巧總結(jié)》、《jQuery擴展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計有所幫助。
- 原生js和jquery實現(xiàn)圖片輪播淡入淡出效果
- 基于jQuery實現(xiàn)淡入淡出效果輪播圖
- 原生js和jQuery實現(xiàn)淡入淡出輪播效果
- jQuery實現(xiàn)的簡單圖片輪播效果完整示例
- 使用JQuery實現(xiàn)圖片輪播效果的實例(推薦)
- 純javaScript、jQuery實現(xiàn)個性化圖片輪播【推薦】
- jQuery簡單自定義圖片輪播插件及用法示例
- jQuery實現(xiàn)的圖片輪播效果完整示例
- jQuery的圖片輪播插件PgwSlideshow使用詳解
- jQuery實現(xiàn)圖片輪播效果代碼(基于jquery.pack.js插件)
- jQuery實現(xiàn)的淡入淡出圖片輪播效果示例
相關(guān)文章
jquery ajax實現(xiàn)下拉框三級無刷新聯(lián)動,且保存保持選中值狀態(tài)
jquery ajax實現(xiàn)下拉框三級無刷新聯(lián)動,且保存保持選中值狀態(tài)。需要的朋友可以過來參考下,希望對大家有所幫助2013-10-10
使用jQuery實現(xiàn)鼠標(biāo)點擊左右按鈕滑動切換
在做web前端開發(fā)的時候經(jīng)常遇到圖片滑動切換特效,接下來通過本文給大家分享使用jQuery實現(xiàn)鼠標(biāo)點擊左右按鈕滑動切換特效,感興趣的朋友參考實現(xiàn)代碼2017-08-08

