以下是 唐宋中国jQuery焦点图轮播滚动切换特效代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!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>
<link href="css/foucs.css" rel="stylesheet" />
<script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="js/foucs.js" type="text/javascript"></script>
</head>
<body><br />
<!-- 代码 开始 -->
<div class="banner">
<div id="img">
<a href="#">
<img src="images/1.jpg" width="1099" height="350" alt="" border="0" /></a>
<a href="#">
<img src="images/2.jpg" width="1099" height="350" alt="" border="0" /></a>
<a href="#">
<img src="images/3.jpg" width="1099" height="350" alt="" border="0" /></a>
<a href="#">
<img src="images/4.jpg" width="1099" height="350" alt="" border="0" /></a>
<a href="#">
<img src="images/5.jpg" width="1099" height="350" alt="" border="0" /></a>
</div>
<div id="SwitchNav">
<div>
<ul>
<li class="nocurrent">1</li>
<li class="nocurrent">2</li>
<li class="nocurrent">3</li>
<li class="nocurrent">4</li>
<li class="nocurrent">5</li>
</ul>
</div>
</div>
</div>
</body>
</html>
JS代码(foucs.js):
$(function (){
var totalnum = $("#img img").size();
var index = 0;
$('#img a img:eq(0)').css('display','inline');
$($("#SwitchNav li")).addClass("nocurrent");
$($("#SwitchNav li")).eq(0).addClass("current");
$("#SwitchNav li").mouseover(function (){
index = $("#SwitchNav li").index(this);
showImg(index);
clearInterval(MyTime);
}
);
$("#SwitchNav li").hover(function (){
if (MyTime){
clearInterval(MyTime);
}
}
,function (){
MyTime = setInterval(function (){
index++;
if (index == totalnum){
index = 0;
}
showImg(index)}
,6600);
}
);
var MyTime = setInterval(function (){
index++;
if (index == totalnum){
index = 0;
}
showImg(index)}
,6600) function showImg(i){
$("#img img") .parent().siblings().find("img").hide() .eq(i).stop(true,true).fadeIn(1800) $("#SwitchNav li") .eq(i).addClass("current") .siblings().removeClass("current");
}
}
)
CSS代码(foucs.css):
*{padding:0;margin:0;}
.banner{position:relative;clear:both;margin-top:25px;width:1095px;margin:0 auto;}
#img img{display:none;border:0;}
#SwitchNav{position:absolute;top:310px;right:0px;}
#SwitchNav div{float:right;margin-right:0px;width:200px;height:256px;background-image:url(../images/adbg.jpg);background-repeat:no-repeat;}
#SwitchNav ul{padding-top:6px;}
#SwitchNav .nocurrent{display:block;width:14px;height:14px;}
#SwitchNav li{float:left;width:14px;height:14px;overflow:hidden;margin-left:12px;_margin-left:6px;margin-right:14px;_margin-right:20px;cursor:pointer;text-indent:999px;list-style:none;}
#SwitchNav .current{display:block;width:14px;height:14px;background-image:url(../images/adbg2.jpg);}