Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TD back ground color on mouseover 1

Status
Not open for further replies.

RottPaws

Programmer
Mar 1, 2002
478
US
Is it possible to change the background color of a table cell when the mouse is pointed at it? I'm trying to get the same effect as an a:hover except I want it to work with a cell instead of a link.

I've tried a number of things but haven't been able to get it to work. I can do it in javascript, but it would be cleaner if I could do it with a css.

If so, what is the syntax? _________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
onmouseover="this.style.background='#dddddd'" onmouseout="this.style.background='original color'"

just put that in your <td> tag [Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
I can do it in javascript, but I was hoping to do it in a css to avoid all the extra code as can be done with <a> tags by setting their color & backgrount-color properties with and withougt hover pseudo-class.

Thanks anyway. _________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
my bad i didnt read through

not possible using css i thinks [Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
You could set a different css class but you would still have to change the class using javascript onMouseover onMouseout. Hope I helped / Thanks for helping
if ((Math.abs(x)<10&&Math.abs(y)<10) && (((parseInt(Math.abs(x).toString()+Math.abs(y).toString())-Math.abs(x)-Math.abs(y))%9)!=0)) {alert(&quot;I'm a monkey's uncle&quot;);}
 
Is there any way of disabling or making transparent the colour of a hyperlink?

I have some .gif buttons against a multicoloured background which I don't want to disturb with the usual blue surround. At a pinch I could make them part of a form (with an onclick...), but would rather avoid this.

Target users may be Linux or Windows, so I don't want to make it too proprietary.

Any other suggestions for workarounds?

Thanks, Linnet
 
I think this thread is talking about what I want to do, and I think it's telling me that it's not possible.

What I want to do is have my CSS respond to JavaScript events (use
Code:
onmouseover
and
Code:
onmouseout
in the .css file to change the characteristics of the class, rather than having to put the event handlers to swap the tag's classes in every single HTML tag that uses the classes).

The way I read the previous posts, this is not possible. Any ideas on whether it's at least in the works? Given JavaScript's ability to alter CSS, it only makes sense that CSS should have the ability to initiate JavaScript calls. But I guess this kind of &quot;feature&quot; could be exploited by malicious scripters, so maybe its absence is a good thing...

[neutral]


JavaStripped
&quot;I did *not* escape. They gave me a day pass.&quot;
 
CSS doesnt really initiate with anything or reacts with anything. all it does is provide a set of standards for how your page will look. CSS is the paint job on a car whereas javascript is like a turbo charger. Its not necessary but it sure helps makes sites nicer and more fun.

[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
Rottpaws

Getting back to the original question: Have you considered this?

<html><head>
<style type=&quot;text/css&quot;>
a {color:black; background:yellow; text-decoration:none}
a:hover {color:black; background:green}
a:active {color:black; background:cyan}
</style>
<title>Changing Table Cell Background on Mouseover</title></head>
<body><div align=&quot;center&quot;>
<table><tr><td>
<a href=&quot;dummy.htm&quot; onclick=&quot;return false&quot;>
Changing Table Cell Background on Mouseover
</a></td></tr></table>
</div></body></html>

Clive
 
May I recommend

for excellent demonstrations and tutorials for CSS powered things that don't normally seem like they ought to be CSS powered.

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top