注册 登录
编程论坛 Ruby论坛

[求助] 一个小问题

haozixp 发布于 2005-08-31 14:29, 3302 次点击

小弟初学dhtml 有段代码不解 望大虾们指教 本来目的是使文字在绿色和红色之间切换 但是变成了红色就不再变了 问什么啊? <html> <head> <title>DHtml举例6</title> <script language="JavaScript"> function change_text(){ if(document.all.Dragon.style.color=="Red"){ document.all.Dragon.style.color="Green"; } else { document.all.Dragon.style.color="Red"; } } </script> <style> h3 {font-size:45}

</style> </head> <body> <br> <h3 id="Dragon" align="center" onmouseover="change_text()" onmouseout="change_text()">我是变色龙!</h3> </body> </html>

1 回复
#2
唐伯猫2006-03-13 16:53

<html>
<head>
<title>DHtml举例6</title>
<script language="JavaScript">
function change_text1()
{
if(document.all.Dragon.style.color=="Red")

{
document.all.Dragon.style.color="Green";

}
else
{
document.all.Dragon.style.color="Red";
}
}
function change_text2()
{
if(document.all.Dragon.style.color=="green")

{
document.all.Dragon.style.color="red";

}
else
{
document.all.Dragon.style.color="green";
}
}
</script>
<style>
h3 {font-size:45}

</style>
</head>
<body>
<br>
<h3 id="Dragon" align="center" onmouseover="change_text1()" onmouseout="change_text2()">我是变色龙!</h3>
</body>
</html>

1