jquery 幻灯片
2014-03-09 22:21
405 查看
<!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=utf-8" />
<title>lin_jquery</title>
<style type="text/css">
.linContainer{margin:10px auto;width:790px;}
.linBox{width:790px;overflow:hidden;height:300px;position:relative;z-index:1;}
.linBoxImg{position:absolute;z-index:10;}
img{border:none;}
.linBoxImg img{float:left;}
.clearBoth{clear:both;}
.linNum{position:absolute; top:230px;right:40px;z-index:100;}
.linNum a{color:#000000;padding:5px;text-decoration:none;}
.linActive{font-weight:bold;}
.linNum a.linActive{color:#ffff00;text-decoration:underline;}
</style>
<script type="text/javascript" src="./js/jquery-1.7.1.min.js"></script>
</head>
<body>
<div class="linContainer">
<div class="linBox">
<div class="linBoxImg">
<a href="x"><img src="./images/reel_1.jpg" /></a>
<a href="2"><img src="./images/reel_2.jpg" /></a>
<a href="3"><img src="./images/reel_3.jpg" /></a>
<a href="4"><img src="./images/reel_4.jpg" /></a>
<br class="clearBoth" />
</div>
<div class="linNum">
<a href="#">1</a><a href="#">2</a><a href="#">3</a><a href="#">4</a>
</div>
</div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
var imgWidth = $(".linBox img").width();
var imgNum = $(".linBox img").size();
var imgTotal = imgWidth * imgNum;
var leftWidth = 0;
var nnn = 0;
var leftTotal = -imgWidth * (imgNum - 1);
$(".linNum a").eq(0).addClass("linActive");
$(".linBoxImg").css({"width": imgTotal});
play = function(){
ok = setInterval(function(){
$(".linBoxImg").animate({left:leftWidth});
leftWidth -= imgWidth;
$(".linNum a").removeClass("linActive");
$(".linNum a").eq(nnn).addClass("linActive");
nnn++;
if(leftWidth < leftTotal){
leftWidth = 0;
nnn = 0;
}
}, 2000);
};
play();
$(".linNum a").hover(function(){
$(".linNum a").removeClass("linActive");
$(this).addClass("linActive");
var nn = $(this).index();
leftWidth = -nn * imgWidth;
$(".linBoxImg").animate({left:leftWidth});
clearInterval(ok);
}, function(){
$(this).removeClass("linActive");
play();
});
$(".linNum a").click(function(){ // 清除点击
return false;
});
});
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>lin_jquery</title>
<style type="text/css">
.linContainer{margin:10px auto;width:790px;}
.linBox{width:790px;overflow:hidden;height:300px;position:relative;z-index:1;}
.linBoxImg{position:absolute;z-index:10;}
img{border:none;}
.linBoxImg img{float:left;}
.clearBoth{clear:both;}
.linNum{position:absolute; top:230px;right:40px;z-index:100;}
.linNum a{color:#000000;padding:5px;text-decoration:none;}
.linActive{font-weight:bold;}
.linNum a.linActive{color:#ffff00;text-decoration:underline;}
</style>
<script type="text/javascript" src="./js/jquery-1.7.1.min.js"></script>
</head>
<body>
<div class="linContainer">
<div class="linBox">
<div class="linBoxImg">
<a href="x"><img src="./images/reel_1.jpg" /></a>
<a href="2"><img src="./images/reel_2.jpg" /></a>
<a href="3"><img src="./images/reel_3.jpg" /></a>
<a href="4"><img src="./images/reel_4.jpg" /></a>
<br class="clearBoth" />
</div>
<div class="linNum">
<a href="#">1</a><a href="#">2</a><a href="#">3</a><a href="#">4</a>
</div>
</div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
var imgWidth = $(".linBox img").width();
var imgNum = $(".linBox img").size();
var imgTotal = imgWidth * imgNum;
var leftWidth = 0;
var nnn = 0;
var leftTotal = -imgWidth * (imgNum - 1);
$(".linNum a").eq(0).addClass("linActive");
$(".linBoxImg").css({"width": imgTotal});
play = function(){
ok = setInterval(function(){
$(".linBoxImg").animate({left:leftWidth});
leftWidth -= imgWidth;
$(".linNum a").removeClass("linActive");
$(".linNum a").eq(nnn).addClass("linActive");
nnn++;
if(leftWidth < leftTotal){
leftWidth = 0;
nnn = 0;
}
}, 2000);
};
play();
$(".linNum a").hover(function(){
$(".linNum a").removeClass("linActive");
$(this).addClass("linActive");
var nn = $(this).index();
leftWidth = -nn * imgWidth;
$(".linBoxImg").animate({left:leftWidth});
clearInterval(ok);
}, function(){
$(this).removeClass("linActive");
play();
});
$(".linNum a").click(function(){ // 清除点击
return false;
});
});
</script>
</body>
</html>
相关文章推荐
- 15个幻灯片效果的JQuery插件
- jquery图片轮播插件仿支付宝2013版全屏图片幻灯片
- 33个优秀的jQuery 教程分享(幻灯片、动画菜单)
- jQuery配合coin-slider插件制作幻灯片效果的流程解析
- jquery特效 幻灯片效果
- SlidesJS基本使用方法和官方文档解释 【Jquery幻灯片插件 Jquery相册插件】
- jQuery高性能跨浏览器全屏幻灯片特效插件
- 60款很酷的 jQuery 幻灯片演示和下载
- jQuery 幻灯片插件(带缩略图功能)
- 基于JSON格式数据的简单jQuery幻灯片插件(jquery-slider)
- 简单的jQuery幻灯片实现
- 30个精美的jQuery幻灯片效果插件和教程
- 支持30+种类型幻灯片|轮播图|旋转木马的强大jQuery插件
- js实现幻灯片效果(基于jquery插件)
- 30个精美的jQuery幻灯片效果插件和教程
- 18款 非常实用 jquery幻灯片图片切换
- jQuery幻灯片带缩略图平移滑动焦点图
- 8款非常棒的响应式 jQuery 幻灯片插件推荐
- 30个精美的jQuery幻灯片效果插件和教程
- 10个用jQuery实现图片幻灯片/画廊效果和源码