七行jquery代码实现图片渐变切换【兼容ie6&IE6+、 Chrome、 Firefox】

<!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"/>
	<meta name="author" content="Nancle from CAU CS101"/>
	<title>jQuery图片渐变切换</title>
	<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
	<style type="text/css">
		ul {
			position: relative;
		}

		ul li {
			display: block;
			position: absolute;
			left: 0;
			top: 0
		}

		img {
			width: 480px;
			height: 320px;
			border: 2px solid #ccc
		}
	</style>
</head>
<body>
	<ul>
		<li><img src="img/1.jpg"/></li>
		<li><img src="img/2.jpg"/></li>
		<li><img src="img/3.jpg"/></li>
		<li><img src="img/4.jpg"/></li>
	</ul>
	</div>
	<script>
	  var switchSpeed = 1000;         //图片切换时间
	  var fadeSpeed = 1500;           //渐变时间
	  setInterval(function () {
		  $('img').last().fadeOut(fadeSpeed, function () {
			  $(this).show().parent().prependTo($('ul'));
		  });
	  }, switchSpeed);
	</script>
</body>
</html> 



效果预览:http://liuyanzhi08.github.io/jquery/simple-carousel/

本文出自:http://blog.csdn.net/nancle/article/details/9706023

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值