SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Dec 2002
    Location
    Sydney, AU
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can onMouseOver, etc. info be part of a class?

    I have a bunch of table cells that are all the same class and all do the same thing when mouseover'ed and mouseout'ed. Can I put the onMouseOver, etc. info into the class in my stylesheet in some way?

    - Tokes

  2. #2
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can call a different class based on the onMouseover event to change the properties of the <td>:

    Code:
    <html>
    
    <head>
    
    <style>
    
    td
    	{
    	height: 50px;
    	width: 200px;
    	}
    td.on
    	{
    	background: blue;
    	color: white;
    	padding: 0px;
    	border: 4px inset grey;
    	}
    td.off
    	{
    	background: black;
    	color: red;
    	padding: 0px;
    	border: 4px outset grey;
    	}
    
    </style>
    
    </head>
    
    <body>
    
    <table><tr><td class="off" onmouseover="this.className='on';" onmouseout="this.className='off';">Queequeg</td></tr></table>
    
    </body>
    
    </html>
    Is that what you're after?

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

    Re: Can onMouseOver, etc. info be part of a class?

    Originally posted by Tokes
    I have a bunch of table cells that are all the same class and all do the same thing when mouseover'ed and mouseout'ed. Can I put the onMouseOver, etc. info into the class in my stylesheet in some way?

    - Tokes
    You can if you're willing to forego IE for the moment and use CSS2:
    Code:
    [onmouseover] {
     text-decoration:none;
    }
    [onmouseout] {
     text-decoration:underline;
    }
    This will change any tag with an "onmouseover" or an "onmouseout" event. Works in Mozilla and Opera (current versions).

    --Vinnie

  4. #4
    SitePoint Member
    Join Date
    Dec 2002
    Location
    Sydney, AU
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by isotope235

    Is that what you're after? [/B]
    That's what im currently doing... thought there might be a better way...

    Obviously not unless I want to use CSS2...

    Thanks anyway guys!

    - Tokes


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
  •