onmouseover / onmouseout advice

Last post 11-05-2009 9:59 AM by TomB1988. 2 replies.

Sort Posts:

  • onmouseover / onmouseout advice

    11-05-2009, 6:31 AM
    • Member
      point Member
    • TomB1988
    • Member since 11-05-2009, 6:21 AM
    • Posts 2

    Hi everyone,

    New to ASP.NET so bear with me. I have created a very simple table, seven columns one row, in the end I would like it to act as my menu. At the moment it contains a hyperlink in each of the seven cells, with a little cell background color (just simple stuff).

    My problem is I have been trying to liven it up by changing the font and background color when the mouse hovers over it, and changing it back again when the mouse is removed. I have tried loads of combinations of code but had no luck, also had a good search on the internet to no avail. Below you can see what I tried so far:


    <td onmouseover="this.style.backgroundColor='red';"
                    onmouseout="this.style.backgroundColor='#797B79';">
                    <a href="http://www.google.com"><span>HOME</span></a></td>

    Now this works fine at the mo, the cell changes to red then back to my custom color. My question is how do I also change the Font/Foreground color aswell as the background color?


    Sorry if this sounds nooby,

    Cheers,

    Tom.

  • Re: onmouseover / onmouseout advice

    11-05-2009, 8:00 AM
    Answer
    • All-Star
      54,677 point All-Star
    • DarrellNorton
    • Member since 04-04-2003, 3:49 PM
    • VA, USA
    • Posts 6,578
    • Moderator
      TrustedFriends-MVPs

    Instead of backgroundcolor, set the forecolor

    Darrell Norton, MVP
    Darrell Norton's Blog


    Please mark this post as answered if it helped you!
  • Re: onmouseover / onmouseout advice

    11-05-2009, 9:59 AM
    • Member
      point Member
    • TomB1988
    • Member since 11-05-2009, 6:21 AM
    • Posts 2

    Thanks for the help, i managed to sort it a different way by creating a style for mouseover then a style for mouseoff, then using these styles as the <td mouseover="styleName blabla...">


Page 1 of 1 (3 items)
Microsoft Communities