鼠标感应渐显图片

来源:互联网 发布:怎么用mac下载炉石 编辑:程序博客网 时间:2024/04/27 20:27
鼠标感应渐显图片
<html>
<head>
<title></title>
<script language="javascript">
var min=10;
var max=100;
var number=1;
function OnMouseOver(obj)
{
  if(obj.changing)
    clearInterval(obj.changing);
  obj.changing=setInterval("add("+obj.id+")",10);
}
function OnMouseOut(obj)
{
  if(obj.changing)
    clearInterval(obj.changing);
  obj.changing=setInterval("sub("+obj.id+")",10);
}
function add(obj)
{
  if(obj.filters.Alpha.Opacity > max)
  {
    clearInterval(obj.changing);
    obj.changing=false;
    obj.filters.Alpha.Opacity = max;
  }
  else
    obj.filters.Alpha.Opacity += number;
  test1.innerText = "img1:"+img1.filters.Alpha.Opacity;
  test2.innerText = "img2:"+img2.filters.Alpha.Opacity;
}
function sub(obj)
{
  if(obj.filters.Alpha.Opacity < min)
  {
    clearInterval(obj.changing);
    obj.changing=false;
    obj.filters.Alpha.Opacity = min;
  }
  else
    obj.filters.Alpha.Opacity += -number;
  test1.innerText = "img1:"+img1.filters.Alpha.Opacity;
  test2.innerText = "img2:"+img2.filters.Alpha.Opacity;
}
</script>
</head>
<body>
<img id='img1' src="http://bbs.51js.com/images/standard/51js.gif" style="filter:Alpha(Opacity=10)" onmouseover="OnMouseOver(this)" onmouseout="OnMouseOut(this)">
<img id='img2' src="http://bbs.51js.com/images/standard/51js.gif" style="filter:Alpha(Opacity=10)" onmouseover="OnMouseOver(this)" onmouseout="OnMouseOut(this)">
<div id='test1'>img1:10</div>
<div id='test2'>img2:10</div>
</body>
</html> 
原创粉丝点击