jQuery圖片輪播

來源:互聯網
上載者:User

標籤:style   io   ar   color   os   sp   on   div   art   

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>lb</title>
<script src="js/jquery-1.8.3.min.js"></script>
<style>
body{width: 992px;margin:0 auto;background-color:lavender;}
.lb{width: 500px;height: 200px;overflow: hidden;z-index: 1;}
ol{position:relative;width: 120px;height: 20px;top:-30px;left:400px;margin: 0;padding: 0;z-index:3;}
ol li{float:left;margin:10px;list-style-image: url("imgs/a.jpg");}
ol li.seleted{list-style-image: url("imgs/b.jpg");}
.tm{width: 500px;height: 30px;background-color:#000; position:absolute;top:170px;z-index:2;filter: alpha(opacity=50);-moz-opacity: 0.50;opacity: 0.50;}
.tm .txt{font-family: 微軟雅黑;font-size: 14px;color: antiquewhite;margin-top: 7px;float: left;}
</style>
</head>
<body>
<div class="lb">
<img src="imgs/icon_swhj1.jpg" width="500px" height="200px">
<img src="imgs/icon_swhj3.jpg" width="500px" height="200px">
<img src="imgs/icon_swhj4.jpg" width="500px" height="200px">
<img src="imgs/icon_swhj5.jpg" width="500px" height="200px">
</div>
<ol class="bn">
<li></li>
<li></li>
<li></li>
<li></li>
</ol>
<div class="tm">
<span class="txt">你好嗎1</span>
<span class="txt">你好嗎2</span>
<span class="txt">你好嗎3</span>
<span class="txt">你好嗎4</span>
</div>
</body>
<script>
$(function(){
var index=0;
var imgs=$(".lb img");//擷取圖片
var txt=$(".tm span");//文字
var sel=$(".bn li");//小圓點
var len=imgs.length;
var timer = null;
//延時切換圖片
function startTime(){
timer = setInterval(function(){
tplb(index);
index++;
if(index==len)
{
index=0;
}
},3000);
}
//停止延時切換
function stopTime(){
if(timer){
clearInterval(timer);
}
}
function tplb(n){
txt.eq(n).fadeIn(10).siblings("span").fadeOut(10);
imgs.eq(n).fadeIn(20).siblings("img").fadeOut(20);
sel.eq(n).css("list-style-image","url(‘imgs/b.jpg‘)").siblings("li").css("list-style-image","url(‘imgs/a.jpg‘)");
}
txt.eq(0).fadeIn(10).siblings("span").fadeOut(10);//初始化
imgs.eq(0).fadeIn(10).siblings("img").fadeOut(10);
sel.eq(0).css("list-style-image","url(‘imgs/b.jpg‘)").siblings("li").css("list-style-image","url(‘imgs/a.jpg‘)");
//滑鼠一上小圓點切換
sel.mouseover(function(){
index=$(this).index("li");
tplb(index);
});
startTime();//初始化
//當滑鼠移動到圖片上是,停止切換
imgs.mouseover(function(){
stopTime();
});
//當滑鼠離開時,開啟切換
imgs.mouseleave(function(){
startTime();
});
});
</script>
</html>

jQuery圖片輪播

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.