js之淡入淡出

<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>

标题名称:js之淡入淡出
本文路径:https://www.cdcxhl.com/article10/ipcjgo.html

成都网站建设公司_创新互联,为您提供做网站网站内链品牌网站建设网站维护网页设计公司小程序开发

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都app开发公司