简单的问题 [英] Simple Problem
问题描述
我试图在
鼠标悬停的表格中替换单元格的背景颜色。翻转功能会根据mi.value进行切换,但
颜色不会改变。任何想法?
非常感谢
--------------------- -----------
< script language = javascript>
函数翻转(mi)
{
if(mi.bgcolor ==" Blue")
{
mi.bgcolor =" White" ;;
textboxy.value =" White";
返回true;
}
else
{
mi.bgcolor =" Blue";
textboxy。=" Blue";
返回true;
}
}
< / script>
< / head>
< body>
< table id =" menu"边界=" 1 QUOT;宽度= QUOT; 100%QUOT; id =" table1">
< tr>
< td bgcolor =" White" ID = QUOT; MI1" onmouseover =" rollover(this);"
onmouseout =" rollover(this);">& nbsp;< / td>
< ; td>& nbsp;< / td>
< td>& nbsp;< / td>
< / tr>
< tr>
< td>& nbsp;< / td>
< td>& nbsp;< / td>
< td>& nbsp;< / td>
< / tr>
< / table>
I am trying to alternate the background colour of a cell in a table on
mouseover. The rollover function does switch based on the mi.value, but the
color does not change. Any ideas ?
Many Thanks
--------------------------------
<script language=javascript>
function rollover( mi )
{
if( mi.bgcolor=="Blue" )
{
mi.bgcolor = "White";
textboxy.value="White";
return true;
}
else
{
mi.bgcolor="Blue";
textboxy.="Blue";
return true;
}
}
</script>
</head>
<body>
<table id="menu" border="1" width="100%" id="table1">
<tr>
<td bgcolor="White" id="MI1" onmouseover="rollover(this);"
onmouseout="rollover(this);"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
推荐答案
news.btinternnet.com写道:
news.btinternnet.com wrote:
我正在尝试替代
鼠标悬停表格中单元格的背景颜色。翻转功能会根据mi.value进行切换,但
颜色不会改变。有什么想法?
非常感谢
----------------------------- ---
< script language = javascript>
语言属性不推荐使用类型:
< script type =" text / javascript">
功能翻转(mi)
{
if(mi.bgcolor ==" Blue")
{
mi.bgcolor =" White" ;;
textboxy.value =" White";
返回true;
}
mi .bgcolor =" Blue";
textboxy。=" Blue" ;;
您的意思是textboxy.value =" Blue" ;;在这里?
返回true;
}
应该是:
if(mi。 style.backgroundColor ==" blue")
{
mi.style.backgroundColor =" white";
return true; < br $>
}
其他
{
mi.style.backgroundColor =" blue";
返回true;
}
}
< / script>
< / head>
< body>
< table id =" menu"边界=" 1 QUOT;宽度= QUOT; 100%QUOT; id =" table1">
< tr>
< td bgcolor =" White" ID = QUOT; MI1" onmouseover =" rollover(this);"
onmouseout =" rollover(this);">& nbsp;< / td>
< td>& nbsp;< ; / td>
< td>& nbsp;< / td>
< / tr>
< tr>
< td>& nbsp; < / td>
< td>& nbsp;< / td>
< td>& nbsp;< / td>
< / tr>
< / table>
I am trying to alternate the background colour of a cell in a table on
mouseover. The rollover function does switch based on the mi.value, but the
color does not change. Any ideas ?
Many Thanks
--------------------------------
<script language=javascript>
The language attribute is deprecated use type instead:
<script type = "text/javascript">
function rollover( mi )
{
if( mi.bgcolor=="Blue" )
{
mi.bgcolor = "White";
textboxy.value="White";
return true;
}
else
{
mi.bgcolor="Blue";
textboxy.="Blue";
Did you mean textboxy.value = "Blue"; here?
return true;
}
Should be instead:
if(mi.style.backgroundColor == "blue")
{
mi.style.backgroundColor = "white";
return true;
}
else
{
mi.style.backgroundColor = "blue";
return true;
}
}
</script>
</head>
<body>
<table id="menu" border="1" width="100%" id="table1">
<tr>
<td bgcolor="White" id="MI1" onmouseover="rollover(this);"
onmouseout="rollover(this);"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
news.btinternnet.com说:
news.btinternnet.com said:
我我试图在鼠标悬停的表格中交替单元格的背景颜色。翻转功能会根据mi.value进行切换,但
颜色不会改变。有什么想法?
I am trying to alternate the background colour of a cell in a table on
mouseover. The rollover function does switch based on the mi.value, but the
color does not change. Any ideas ?
是什么让你认为表格单元格有一个名为bgcolor的属性?
更改所有引用到mi.bgcolor到mi.style.backgroundColor。
另外,修复以下行:
textboxy。=" Blue";
What made you think that table cells have a property named "bgcolor"?
Change all references to "mi.bgcolor" to "mi.style.backgroundColor".
Also, fix the line that reads:
textboxy.="Blue";
非常感谢,这是一种享受的好处
列出的样式属性在哪里,是否有可以推荐的网址
" web.dev" <我们******** @ gmail.com>在消息中写道
news:11 ********************* @ o13g2000cwo.googlegro ups.com ...
Thanks very much, that worked a treat
Where are the style attributes listed, is there a url you could recommend
"web.dev" <we********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
news.btinternnet.com写道:
news.btinternnet.com wrote:
我试图在鼠标悬停的表格中交替单元格的背景颜色。翻转功能根据mi.value进行切换,但
颜色不会改变。有什么想法?
非常感谢
----------------------------- ---
< script language = javascript>
I am trying to alternate the background colour of a cell in a table on
mouseover. The rollover function does switch based on the mi.value, but
the
color does not change. Any ideas ?
Many Thanks
--------------------------------
<script language=javascript>
语言属性不推荐使用类型:
< script type =" text / javascript">
The language attribute is deprecated use type instead:
<script type = "text/javascript">
function rollover(mi)
{
if(mi.bgcolor ==" Blue" ;)
{
mi.bgcolor ="白色" ;;
textboxy.value ="白色" ;;
返回true;
}
{
mi.bgcolor =" Blue" ;;
textboxy。=" Blue" ;;
function rollover( mi )
{
if( mi.bgcolor=="Blue" )
{
mi.bgcolor = "White";
textboxy.value="White";
return true;
}
else
{
mi.bgcolor="Blue";
textboxy.="Blue";
你的意思是textboxy.value =" Blue" ;;在这里?
Did you mean textboxy.value = "Blue"; here?
返回true;
}
return true;
}
应该是:
if(mi。 style.backgroundColor ==" blue")
{
mi.style.backgroundColor =" white" ;;
return true;
}
else > {
mi.style.backgroundColor =" blue" ;;
返回true;
}
Should be instead:
if(mi.style.backgroundColor == "blue")
{
mi.style.backgroundColor = "white";
return true;
}
else
{
mi.style.backgroundColor = "blue";
return true;
}
}
< / script>
< / head>
< body>
< table id =" menu"边界=" 1 QUOT;宽度= QUOT; 100%QUOT; id =" table1">
< tr>
< td bgcolor =" White" ID = QUOT; MI1" onmouseover =" rollover(this);"
onmouseout =" rollover(this);">& nbsp;< / td>
< td>& nbsp;< ; / td>
< td>& nbsp;< / td>
< / tr>
< tr>
< td>& nbsp; < / td>
< td>& nbsp;< / td>
< td>& nbsp;< / td>
< / tr>
< / table>
}
</script>
</head>
<body>
<table id="menu" border="1" width="100%" id="table1">
<tr>
<td bgcolor="White" id="MI1" onmouseover="rollover(this);"
onmouseout="rollover(this);"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
这篇关于简单的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!