为了账号安全,请及时绑定邮箱和手机立即绑定

求帮我看看 鼠标移出没反应 问题出哪里了?

<!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" />

<title>透明度的改变 </title>

<style type="text/css">

*{

margin:0px; padding:0px;

}

#box{

width:300px;

height:250px;

filter:alpha(opacity=:30);

opacity:0.3;

background:red;

}

</style>

<script>

window.onload = function()

{

var Obox = document.getElementById("box");

Obox.onmouseover = function()

{

startcharge(100);

}

Obox.onmouseout = function()

{

startcharge(30);

}

var timer = null;

var al = 30;

function startcharge(Target)

{

clearInterval(timer);

var Obox = document.getElementById("box"); 

timer =setInterval(function(){

var speed = 0;

if(speed >Target)

{

speed = -10;

}

else

{

speed = 10;

}

if( al ==Target)

{

clearInterval(timer);

}

else

{

al+=speed;

Obox.style.opacity = al/100;

Obox.style.filter = "alpha(opacity:"+alpha+")";

}

},30)

}

}


</script>


</head>


<body>

<div id="box"></div>

</body>

</html>


正在回答

2 回答

var speed = 0;

if(speed >Target)

{

speed = -10;

}

else

{

speed = 10;

}

判断语句错了,你都定义了speed为0,还比较什么。

应该是al与Target的比较。

个人看法,希望能帮到你


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

求帮我看看 鼠标移出没反应 问题出哪里了?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信