Jump to content

OnMouseOver AND OnMouseOut


AndieB

Recommended Posts

Hi all,

 

 

I'd like to create a javascript that changes the background-color of a ROW in a table when moving the mouse pointer over the ROW. I've seen some examples, but these examples have written the background-color values static in each <TR> tag.

 

I want a function that should be called upon. Is it possible to FETCH the current background-color value in the onmouseover function to be used by the onmouseout function, so that the background-color goes back to its origin color?

 

The reason I ask, is because the TABLE itself and the ROWS/CELLS are created with PHP script and in that SCRIPT the background-color value is defined in a STRING.

 

Anyone who can assist me?

 

Thank you in advance!

 

--Andreas

Link to comment
https://forums.phpfreaks.com/topic/141230-onmouseover-and-onmouseout/
Share on other sites

You should be able to use the hover pseudo class on the TR tag.

 

for instance in your CSS

tr:hover {
    background-color:white;
}

 

you may or may not have some IE problems though, but if you did you could very well use a javascript fix to set the class of the particular TR tag to something else. 

 

then you can have

tr.over, tr:hover {
    background-color:white;
}


    
    

 

Or if you please you could change only the background color.  I suggest changing the class though


    
    

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.