首页 > Web开发 > 详细

js之淡入淡出

时间:2017-03-15 19:18:13      阅读:206      评论:0      收藏:0      [点我收藏+]
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
#div1{width:200px;height:200px;filter:alpha(opacity:30);opacity:0.3;}
</style>
<script>
window. ()
{
	var oDiv=document.getElementById(‘div1‘);
	oDiv. ()
	{
		startMove(100);
	};
	oDiv. ()
	{
		startMove(30);
	};
};
var timer=null;
var alpha=30;
function startMove(number)
{
	var oDiv=document.getElementById(‘div1‘);
	
	clearInterval(timer);
	timer=setInterval(function ()
	{
		var speed=0;
		if(alpha<number)
		{
			speed=5;
		}
		else
		{
			speed=-5;	
		}
		if(alpha==number)
		{
			clearInterval(timer);	
		}
		else
		{
			alpha+=speed;
			oDiv.style.filter=‘alpha(opacity=‘+alpha+‘)‘;
			oDiv.style.opacity=alpha/100;	
		}
	},30);
};
</script>
</head>

<body>
</body>
<div id="div1">
<img src="file:///E|/250-chocolate-19-momme-seamless-silk-bedding-set-cymbidium-02.jpg" />
</div>
</html>


本文出自 “12380959” 博客,请务必保留此出处http://12390959.blog.51cto.com/12380959/1906907

js之淡入淡出

原文:http://12390959.blog.51cto.com/12380959/1906907

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!