DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery常見問題 >> jQuery焦點新聞圖片輪播
jQuery焦點新聞圖片輪播
編輯:JQuery常見問題     
查看效果:http:///keleyi/phtml/image/13.htm

完整代碼:

<!DOCTYPE html>
<html>
<head><meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>圖片輪播,新聞輪播,焦點新聞輪播-</title><base target="_blank" />
<script type="text/javascript" src="http:///keleyi/pmedia/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var index = 0;
var slideFlag = true;
var length = $(".roll-news-image img").length;

function showImg(i) {
$(".roll-news-image img")
.eq(i).stop(true, true).fadeIn(800)
.siblings("img").hide();

$(".roll-news-index li").removeClass("roll-news-index-hover");
$(".roll-news-index li").eq(i).addClass("roll-news-index-hover");

$(".roll-news-title a")
.eq(i).stop(true, true).fadeIn(800)
.siblings("a").hide();
}
showImg(index);

$(".roll-news-index li").click(function () {
index = $(".roll-news-index li").index(this);
showImg(index);
slideFlag = false;
});

function autoSlide() {
setInterval(function () {
if (slideFlag) {
showImg((index + 1) % length);
index = (index + 1) % length;
}
slideFlag = true;
}, 3000);
}

autoSlide();

});
</script>
<style type="text/css">
* {
padding:0px;
margin:0px;
}
.roll-news-keleyi-com {
width:480px;
height:300px;
border:solid 1px #c1c1c1;
}
.roll-news-index-hover {
background-color:white;
}
.roll-news-image img {
width:480px;
height:300px;
}
.roll-news-index {
position:relative;
top:-50px;
margin-right:5px;
float:right;
}
.roll-news-index {
}
.roll-news-index li {
list-style:none;
float:left;
font-size:12px;
font-weight:600;
width:18px;
height:16px;
line-height:16px;
cursor:pointer;
margin:0 3px;
background-image:url(opacity_50.png);
text-align:center;
}
.roll-news-title {
position:relative;
top:-25px;
padding-left:10px;
height:22px;
line-height:20px;
background:url(opacity_50.png);
}
.roll-news-title a {
font-size:12px;
text-decoration:none;
color:white;
background-color:gray
}
.roll-news-title a:hover {
color:red;
}
</style>
</head>
<body>
<div style="width:500px;margin:0px auto;">
<h2>圖片輪播-</h2>
<div class="roll-news-keleyi-com">
<div class="roll-news-image">
<img src="http://down./images/bing/2013-8-10_Toulouse_ZH-CN7808794431_keleyi.jpg">
<img src="http://down./images/bing/2013-9-27_BoliviaSalt_ZH-CN10259156901_keleyi.jpg" style="display:none">
<img src="http://down./images/bing/2013-8-22_KataleKhorCave_ZH-CN6707191757_keleyi.jpg" style="display:none">
</div>
<div class="roll-news-index">
<ul>
<li class="roll-news-index-hover">1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
<div class="roll-news-title">
<a href="http:///a/bjac/s3sw6q5t.htm">圖片輪播切換匯總</a>
<a href="http:///a/bjac/xkqqoac2.htm" style="display:none">選美大賽</a>
<a href="http:///a/bjac/600xsi0s.htm" style="display:none">俄羅斯方塊游戲</a>
</div>
</div><a href="http:///a/bjac/0ttmf3ib.htm">原文</a></div>
</body>
</html>


更多圖片切換效果:http:///a/bjac/s3sw6q5t.htm
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved