cypher3ll3
asked on
onMouseOver, onMouseOut, background-color...
Hi,
I have a following HTML code:
<TR onMouseOver="this.style.ba ckground=' #C1D1E2'" onMouseOut="this.style.bac kground='# F0F8FF'">
<TD style="background-color:#F 0F8FF;"> blah </TD>
</TR>
When a mouse is over this row, the background color does not change. Is this because I specify the bg color in the <TD> tag? 'Cause when I remove that from <TD>, onMouseOver and onMouseOut work fine. Is there any way that I can accomplish the both, leaving the bg color in <TD> and changing its bg color when the mouse is over that row.
TIA,
gibb
I have a following HTML code:
<TR onMouseOver="this.style.ba
<TD style="background-color:#F
</TR>
When a mouse is over this row, the background color does not change. Is this because I specify the bg color in the <TD> tag? 'Cause when I remove that from <TD>, onMouseOver and onMouseOut work fine. Is there any way that I can accomplish the both, leaving the bg color in <TD> and changing its bg color when the mouse is over that row.
TIA,
gibb
It may also be a browser quirk. I've had problems with dynamically changing styles when the style I'm setting is not exactly specified inline, the way you are setting background dynamically but don't have a background property set for the TR. Try setting a background explicitly for the TR.
How can the OnMouseover event be set to an Onclick? I wanted to take something similar so that when the user clicks on the row it sets the bkg color and (via a checkbox selection on that row) and yet when they check a checkobx on another row, it resets the color back on the first row and sets this newly select row (via checkbox) to a certain color?
ASKER
hexagon47,
I tried your solution, but I got a javascript runtime error. It indicates that myRow.style is NULL or not an object. I did specify myRow as you showed it in the comment. Any idea?
TIA,
gibb
I tried your solution, but I got a javascript runtime error. It indicates that myRow.style is NULL or not an object. I did specify myRow as you showed it in the comment. Any idea?
TIA,
gibb
What was the browser you tried with? You could try referring to rows by table's row collection.
ASKER
Kovis,
IE6. Table's row collection... can you point me to that???
TIA,
gibb
IE6. Table's row collection... can you point me to that???
TIA,
gibb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
cypher
kasandra should be right,
regarding the row collection
go to http://msdn.microsoft.com/library/default.asp
on the left menu go web development / html and dynamic html / sdk documentation / reference / objects
there you have the "table" object and all the collection blonging to it (yes row as well)
kasandra should be right,
regarding the row collection
go to http://msdn.microsoft.com/library/default.asp
on the left menu go web development / html and dynamic html / sdk documentation / reference / objects
there you have the "table" object and all the collection blonging to it (yes row as well)
Thanks for the A cypher! :)
you can put an id to both the row and the cell and change the action according to your needs
the code below should do it
<table border="1">
<tr onMouseOver="myRow.style.b
<td style="background-color:#F
</tr>
</table>
hope that is what you meant
p.s. if you'd have more cells in the table you would see the effect in the cell where you did not specify a background-color