JQUERY多图切换轮换图片播放特效,解决了鼠标停止图片闪烁的问题,运行看不到效果请多刷新一下.
[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=utf-8" />
<link href="http://img.daqianduan.com/ui/favicon.ico" rel="shortcut icon">
<title>JQUERY多图切换轮换图片播放特效- demo by js.alixixi.com</title>
<link type="text/css" rel="stylesheet" href="http://www.daqianduan.com/demo/css/common.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<style type="text/css">
.slide{position:relative;width:516px;height:222px;padding:10px;border:#ccc 1px solid;}
.slide .pic{overflow:hidden;width:420px;float:left;position:relative;}
.slide .pic a{display:none;}
.slide .pic img{width:405px;height:220px;border:1px solid #e4e4e4;}
.slide .pic a.cur{display:block;}
.slide .thumb{width:96px; position: absolute; bottom: 10px; right: 15px;}
.slide .thumb a{display:block;height:50px;margin-bottom:2px;border:#fff 1px solid;padding:1px;}
.slide .thumb a img{ height:50px;}
.slide .thumb .cur, .slide .thumb a:hover{border:#ff6700 1px solid;}
</style>
<div class="slide">
<div class="pic">
<a style="display: block;" class="cur" href="#"><img src="http://shaoerw.com/img/slimg/dw/images/031.jpg"></a>
<a href="#"><img src="http://wenwen.soso.com/p/20100728/20100728192959-620664199.jpg"></a>
<a href="#"><img src="http://pic8.nipic.com/20100729/3409334_102244002243_2.jpg"></a>
<a href="#"><img src="http://pic7.nipic.com/20100430/4807156_171014093416_2.jpg"></a>
</div>
<div class="thumb">
<a class="cur" href="">0</a>
<a href="">1</a>
<a href="">2</a>
<a href="">3</a>
<!--也可以放缩略图-->
</div>
</div>
<script type="text/javascript">
var defaultOpts = { interval: 4000, fadeInTime: 300, fadeOutTime: 200 };
var _titles = $(".slide .thumb a");
var _bodies = $(".slide .pic a");
var _count = _titles.length;
var _current = 0;
var _intervalID = null;
var stop = function() { window.clearInterval(_intervalID); };
var slide = function(opts) {
if (opts) {
_current = opts.current || 0;
} else {
_current = (_current >= (_count - 1)) ? 0 : (++_current);
};
_bodies.filter(":visible").fadeOut(defaultOpts.fadeOutTime, function() {
_bodies.eq(_current).fadeIn(defaultOpts.fadeInTime);
_bodies.removeClass("cur").eq(_current).addClass("cur");
});
_titles.removeClass("cur").eq(_current).addClass("cur");
};
var go = function() {
stop();
_intervalID = window.setInterval(function() { slide(); }, defaultOpts.interval);
};
var itemMouseOver = function(target, items) {
stop();
var i = $.inArray(target, items);
slide({ current: i });
};
_titles.hover(function() { if($(this).attr('class')!='cur'){itemMouseOver(this, _titles); }else{stop();}}, go);
_bodies.hover(stop, go);
go();
</script>
<span style=" display:none;">
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fa9b886889d9f2c3db067e0d618412df5' type='text/javascript'%3E%3C/script%3E"));
</script>
</span>
</body>
</html>
相关内容推荐
热门源码