87,910
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jQuery淡入淡出</title>
<style type="text/css">
body { background-color:#F3F3F3; color:#333; }
body, input, textarea, select { font-size:12px; font-family:"微软雅黑", "宋体", Tahoma; }
body, h1, h2, h4, p, ul, dl, dd, form { margin:0; }
ul, ol { padding-left:0; list-style:none outside; }
img { border:0; display:block; }
#play { margin:100px auto 0; width:346px; height:191px; position:relative; overflow:hidden; }
#loading { width:100%; line-height:191px; background-color:#FFF; text-align:center; color:#C00036; position:absolute; z-index:13; left:0; top:0; }
#play_bg { position:absolute; bottom:0; left:0; background-color:#000; height:26px; width:100%; filter:alpha(Opacity=70); opacity:0.7; z-index:10; }
#play_info{ position:absolute; bottom:0; left:0; padding:0 10px; font-weight:bold; font-size:14px; line-height:28px; color:#fff; z-index:11; }
#play_text { position:absolute; z-index:12; }
#play_text li { width:14px; line-height:14px; text-align:center; float:left; background-color:#000; color:#FFF; cursor:pointer; }
#play_text li.hover { background-color:#FFF; color:#000; }
#play_list div { display:none; width:346px; height:191px; position:absolute; overflow:hidden; }
#play_list img { width:346px; height:191px; }
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
</head>
<body>
<div id="play">
<div id="loading"><strong>Loading...</strong></div>
<div id="play_bg"></div>
<div id="play_info"></div>
<ul id="play_text">
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
</ul>
<div id="play_list">
<div><a href="#"><img onload="finishImg()" src="http://img.article.pchome.net/new/w600/00/25/81/29/pic_lib/wm/fjxw_4.jpg" alt="图片标题1" /></a></div>
<div><a href="#"><img onload="finishImg()" src="http://hiphotos.baidu.com/airskyandsea/pic/item/80ad8e1fe7669b5af724e4f1.jpg" alt="图片标题2" /></a></div>
<div><a href="#"><img onload="finishImg()" src="http://image5.poco.cn/mypoco/myphoto/20080404/20/37032281200804042047054026803269614_006_640.jpg" alt="图片标题3" /></a></div>
<div><a href="#"><img onload="finishImg()" src="http://image.poco.cn/mypoco/myphoto/20071016/17/3950745520071016175044609_003_640.jpg" alt="图片标题4" /></a></div>
</div>
</div>
<script type="text/javascript">
var t = n = 0, count = $("#play_list div").size(), picNum = 0;
function finishImg(){
picNum++;
if(picNum == count){
$('#loading').fadeOut('fast');
focusImg();
}
}
function focusImg(){
$("#play_list div").eq(0).show();
$("#play_info").html($("#play_list div").eq(0).find("img").attr('alt'));
$("#play_text li").eq(0).addClass('hover');
$("#play_text li").click(function(){
var i = $(this).index(); n = i;
if (i >= count) return;
$("#play_info").html($("#play_list div").eq(i).find("img").attr('alt'));
$("#play_list div").filter(":visible").fadeOut(800);
$("#play_list div").eq(i).fadeIn(800);
$(this).addClass('hover').siblings().removeClass('hover');
});
t = setInterval("showAuto()", 2000);
$("#play").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 2000)});
}
function showAuto(){
n = n >= (count - 1) ? 0 : ++n;
$("#play_text li").eq(n).trigger('click');
}
</script>
</body>
</html>