W3C home > Mailing lists > Public > www-style@w3.org > March 2003

Re: CSS class and changing with javascript

From: Steve H <steveftc@hotmail.com>
Date: Sat, 29 Mar 2003 23:02:42 -0500 (EST)
Message-ID: <F18BH5EfR3ljnzETDMx000465c5@hotmail.com>
To: www-style@w3.org



Hey Jonathan,
You need to access the object whose style you're changing, instead of trying 
to access the class. I've gotten this to work:

<style>
.classOne{color:green;}
</style>
<script>
function changeIt(obj)\
{
obj.style.color = "red";
}
</script>
<table>
<tr>
<td id="objectOne" class="classOne" 
onMouseOver="changeIt(this)">something</td>
</tr>
</table>

Let me know if you have any problems, questions, etc..

~Steve


_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail
Received on Monday, 31 March 2003 07:18:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:20 GMT