Jump to content

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


    
    

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.