js圖片輪播

來源:互聯網
上載者:User

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

<html>
<head>
<meta charset="utf-8"/>
<title>圖片滾動</title>
<style>
*{margin:0px;padding:0px;font-size:14px;}
.tpLunbo{position:relative;list-style-type:none;height:240px;width:922px;}
.tpLunbo ul li{position:absolute;heiht:240px;withd:922px;left:0px;top:0px;display:none;}
.LunBo ul li.CurrentPic { display: block;}
.tpLunbo img{width:922px;;height:240px;}
.lunboPage {position: absolute;right:1px;bottom:1px;width: 50px;text-align:right;background-color: #006058;padding-left:10px;float:right;}
.lunboPage span {height: 15px;width: 10px;display: block;line-height: 20px;text-align: center;margin-top: 5px;margin-bottom: 5px;float: left;cursor:pointer;}
.CurrentPage { background-color: #009991;}
</style>
<script src="jquery-1.8.3.min.js"></script>
</head>
<body>
<div class="tpLunbo">
<ul>
<li class="CurrentPic"><img src="1.jpg"/></li>
<li><img src="2.jpg"/></li>
<li><img src="3.jpg"/></li>
</ul>
<div class="lunboPage">
<span class="CurrentPage">1</span>
<span>2</span>
<span>3</span>
</div>
</div>
</body>
<script type="text/javascript" language="javascript">
var PicTotal = 5;
var CurrentIndex;
var ToDisplayPicNumber = 0;
$(".lunboPage span").click(DisplayPic);
function DisplayPic() {
CurrentIndex = $(this).index();// 測試是父親的第幾個兒子
$(this).parent().children().removeClass("CurrentPage")// 刪除所有同級兄弟的類屬性
$(this).addClass("CurrentPage");// 為當前元素添加類
var Pic = $(this).parent().parent().children("ul");
$(Pic).children().hide();// 隱藏全部圖片
$(Pic).children("li").eq(CurrentIndex).show();// 顯示指定圖片
}
function PicNumClick() {
$(".lunboPage span").eq(ToDisplayPicNumber).trigger("click");
ToDisplayPicNumber = (ToDisplayPicNumber + 1) % PicTotal;
setTimeout("PicNumClick()",1000);
}
setTimeout("PicNumClick()",1000);
</script>
</html>

     </body>

</html>

js圖片輪播

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.