haozixp 发表于 2005-8-31 14:29

[求助] 一个小问题

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

唐伯猫 发表于 2006-3-13 16:53

<P>&lt;html&gt;<BR>&lt;head&gt;<BR>&lt;title&gt;DHtml举例6&lt;/title&gt;<BR>&lt;script language="JavaScript"&gt;<BR>function change_text1()<BR>{<BR>if(document.all.Dragon.style.color=="Red")</P>
<P>              {<BR>                    document.all.Dragon.style.color="Green";<BR>                      <BR>           }<BR>          else<BR>                {<BR>                      document.all.Dragon.style.color="Red";<BR>               } <BR>}<BR>function change_text2()<BR>{<BR>if(document.all.Dragon.style.color=="green")</P>
<P>              {<BR>                    document.all.Dragon.style.color="red";<BR>                      <BR>           }<BR>          else<BR>                {<BR>                      document.all.Dragon.style.color="green";<BR>               } <BR>}<BR>&lt;/script&gt;<BR>&lt;style&gt; <BR>h3 {font-size:45}</P>
<P>&lt;/style&gt;<BR>&lt;/head&gt;<BR>&lt;body&gt;<BR>&lt;br&gt;<BR>&lt;h3 id="Dragon" align="center" onmouseover="change_text1()" onmouseout="change_text2()"&gt;我是变色龙!&lt;/h3&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;<BR></P>

页: [1]

编程论坛