...

View Full Version : Setting table cell style attributes



snoodle
06-19-2007, 02:01 AM
given a cell from a table...
function Tbl_GetCell(tbl, row, col)
{
var theRow = tbl.getElementsByTagName("tr")[row];
return theRow.getElementsByTagName("td")[col];
}

I can set attributes like width, height, and align, but how can I set cell style info?

cell = GetCell(tbl,row,col)
these work fine... cell.align = "center"; cell.height = 22;
but this doesn't... cell.style = "font-weight: bold; text-decoration: blink"

help?

glenngv
06-19-2007, 04:49 AM
cell.style.fontWeight = "bold";
cell.style.textDecoration = "blink";
But it's better to just set the CSS classname so that the code is shorter and all the properties are set at once.


<style type="text/css">
.test {
font-weight: bold;
text-decoration: blink;
/*...and so on*/
}
</style>

cell.className = "test";

snoodle
06-19-2007, 06:18 AM
thanks glenn. amazing how the simplest stuff is sometimes so hard to find. you're my hero. thanks again.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum