-
CSS question
hi,
ok, heres my question.
i have an "OnMouseOver" and an "OnMouseOut", and for each mouseover and mouse out, its the same sequece(change color)
can i assign it to a "function", so that itll change the color, instead of having to put the code in each section?
thanks
nabeel
-
If you are only coding for IE you can use this:
<style>
a:hover { color:green; font-weight:bold; }
</style>
Again, this will only work for IE. The above style will work for all links on the page.
-
Yeah, you can.
Code:
<script>
function changecolor(id, color)
{
id.style.color = color;
}
</script>
...
<span onMouseOver="changecolor(this,'red')" onMouseOut="changecolor(this,'black')">
turns red on mouseover, black on mouseout
</span>
-
I'm afriad you can't. 'Least I'm not finding anything in the CSS specs at W3C. I would like to do the same thing. It makes sense to me.
-
well, right now im using:
Code:
<td height="29" onMouseOver="style.backgroundColor='#CCCC99'; borderColor='#000000';" onMouseOut="style.backgroundColor='#F0F0E1'; borderColor='#F0F0E1';">
and its for only a few cells, like ones in which the subject is. instead of copy and pasting that whole bit, i wanna just have it link. well if you cant do it that way then :rolleyes:
-
well, right now im using:
Code:
<td height="29" onMouseOver="style.backgroundColor='#CCCC99'; borderColor='#000000';" onMouseOut="style.backgroundColor='#F0F0E1'; borderColor='#F0F0E1';">
and its for only a few cells, like ones in which the subject is. instead of copy and pasting that whole bit, i wanna just have it link. well if you cant do it that way then :rolleyes:
thanks
-
You can make functions, like Wynd suggested, you just can't put this in CSS.