[thelist] Is it possible to change the table cell bgcolor by JavaScript?
Joshua OIson
joshua at alphashop.net
Tue Jan 23 15:44:40 CST 2001
Winfried,
If you are using ie, the technique for changing the cell color is simple.
Give the cell a unique identifier using the id attributes, a la:
<table>
<tr>
<td id="unique123">My Info</td>
</tr>
</table>
You can access the cell in JS using:
document.all.unique123
You can access the cells style properties using:
document.all.unique123.style
You can access the cell's background color property using:
document.all.unique123.style.backgroundColor
So, you can set it to blue using:
document.all.unique123.style.backgroundColor='blue'
The general rule for style property names is that the JS equivalents are the
same as the CSS name except that the hyphens are removed and the characters
after the CSS hyphens are capitalized.
Again, this technique works for ie 4.0+. Resources for the NN and the NS6
equivalents can be found at http://developer.netscape.com/tech/css/
Good luck,
-joshua
More information about the thelist
mailing list