Jquery特效一:图片轮换显示
2011-02-14 10:56
288 查看
效果图及代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<style type="text/css">
* {margin:0;padding:0;font-size:12px;font-family:Verdana;}
img {border:0}
#pic{margin:5px;width:300px;height:200px;overflow:hidden;cursor:pointer;}
#play{position:absolute;margin-left:200px;margin-top:-30px;}
#play a{text-decoration: none;border:1px solid #CEDEF7;background-color:#E8FCEB;width:20px;height:20px;color:#2F49DF;display:block;float:left;text-align:center;line-height:20px;margin-right:3px;}
</style>
<script type="text/javascript">
var _c = _h = 0;
$(function () {
$('#play > a').click(function () {
var i = $(this).attr('alt') - 1;
clearInterval(_h);
_c = i;
play();
change(i);
})
$("#pic img").hover(function () { clearInterval(_h) }, function () { play() });
play();
})
function play() {
_h = setInterval("auto()", 3000);
}
function change(i) {
$('#play > a').css('background-color', '#E8FCEB').eq(i).css('background-color', '#C6FF5E').blur();
$("#pic img").hide().eq(i).fadeIn('slow');
}
function auto() {
_c = _c > 2 ? 0 : _c + 1;
change(_c);
}
</script>
<title>js图片播放轮换</title>
</head>
<body>
<div id="pic">
<img src="http://www.cssrain.cn/demo/pic/cssrain-logo.JPG" width="300" height="200" alt="" />
<img src="http://www.cssrain.cn/demo/pic/usbmingpian.jpg" width="300" height="200" alt="" />
<img src="http://www.cssrain.cn/demo/pic/ganyingdeng2.jpg" width="300" height="200" alt="" />
<img src="http://www.cssrain.cn/demo/pic/ganyingdeng.jpg" width="300" height="200" alt="" />
</div>
<div id="play">
<a href="###" alt="1" style="background-color:#C6FF5E">1</a>
<a href="###" alt="2" >2</a>
<a href="###" alt="3" >3</a>
<a href="###" alt="4" >4</a>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<style type="text/css">
* {margin:0;padding:0;font-size:12px;font-family:Verdana;}
img {border:0}
#pic{margin:5px;width:300px;height:200px;overflow:hidden;cursor:pointer;}
#play{position:absolute;margin-left:200px;margin-top:-30px;}
#play a{text-decoration: none;border:1px solid #CEDEF7;background-color:#E8FCEB;width:20px;height:20px;color:#2F49DF;display:block;float:left;text-align:center;line-height:20px;margin-right:3px;}
</style>
<script type="text/javascript">
var _c = _h = 0;
$(function () {
$('#play > a').click(function () {
var i = $(this).attr('alt') - 1;
clearInterval(_h);
_c = i;
play();
change(i);
})
$("#pic img").hover(function () { clearInterval(_h) }, function () { play() });
play();
})
function play() {
_h = setInterval("auto()", 3000);
}
function change(i) {
$('#play > a').css('background-color', '#E8FCEB').eq(i).css('background-color', '#C6FF5E').blur();
$("#pic img").hide().eq(i).fadeIn('slow');
}
function auto() {
_c = _c > 2 ? 0 : _c + 1;
change(_c);
}
</script>
<title>js图片播放轮换</title>
</head>
<body>
<div id="pic">
<img src="http://www.cssrain.cn/demo/pic/cssrain-logo.JPG" width="300" height="200" alt="" />
<img src="http://www.cssrain.cn/demo/pic/usbmingpian.jpg" width="300" height="200" alt="" />
<img src="http://www.cssrain.cn/demo/pic/ganyingdeng2.jpg" width="300" height="200" alt="" />
<img src="http://www.cssrain.cn/demo/pic/ganyingdeng.jpg" width="300" height="200" alt="" />
</div>
<div id="play">
<a href="###" alt="1" style="background-color:#C6FF5E">1</a>
<a href="###" alt="2" >2</a>
<a href="###" alt="3" >3</a>
<a href="###" alt="4" >4</a>
</div>
</body>
</html>
相关文章推荐
- jQuery实现点击小图片淡入淡出显示大图片特效
- jquery插件orbit.js实现图片折叠轮换特效
- jQuery css3鼠标悬停图片显示遮罩层动画特效
- jquery特效---点击图片显示大图片效果
- jquery 视觉特效(鼠标悬停时依次显示图片)
- jquery-图片特效,如何实现图片的轮换(一)
- jQuery实现点击小图片淡入淡出显示大图片特效
- jquery-图片特效,如何实现图片的轮换(二)
- jquery插件鼠标移上去当前列表显示图片的特效
- 支付宝抢红包图片随机显示jQuery特效
- loner_li JQuery插件 实现相册光箱特效(后台数据库调图片和前台直接显示)
- jquery Banner 图片自动轮换显示
- jQuery css3鼠标悬停图片显示遮罩层动画特效
- JQuery特效多张图片上传
- Jquery实现点击切换图片并隐藏显示内容(2种方法实现)
- jquery鼠标滑过展示图片时显示详情
- JQuery实现图片轮换
- 基于jQuery适合做图片类网站的特效
- [转]jquery 鼠标放在图片上显示图片的放大镜效果jqzoom_ev-2.3
- JavaScript判断远程图片是否存在,加载完成:onerror 属性- & jQuery实现(如果因为网络或图片的原因发生异常,则显示该图片)~