SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onMouseOver, CSS, and cell bgcolor

    How would I go about using an onMouseOver to change the background color of a cell in a table?

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    onMouseover="this.style.backgroundColor='#f90'". This'll work in NS 6 and IE 4+. For NS it takes some layers and ilayers, but check out my script that does exactly this: http://anarchos.xs.mw/crossmenu.phtml

  3. #3
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, I was using bgcolor. Thanks.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Nowhere Important.
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is there a way to specify that in an external css file? I want a whole row to change color when the mouse moves over it, but I want to add it to the color specification for the row instead of addind tags in my code.

  5. #5
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can create a function that will do that. Then put the function into a .js file and link to it. Then, you can call the function and specify the color yo uwant to use right there...
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  6. #6
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Nowhere Important.
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm afraid that js is currently out of my realm of abilities. What I'm getting is that there is no easy way to take this:

    <td class="yourclass" onMouseOver="this.className='yourotherclass';" onMouseOut="this.className='yourclass';">

    and specify the mouseovers in "style.css"?

  7. #7
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your script should work for newer browsers.

    Put something like this in your stylesheet:

    Code:
    td.yourclass
      {
      background:#000000;
      }
    td.yourotherclass
      {
      background:#003366;
      }
    HTH


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •