View Full Version : CSS formatting DOM table cells. Help.

07-11-2004, 11:16 PM
The following code add rows and cells nicely in a table.
I need to apply some css formatting like fontfamily, fontsize, padding, etc., to the cells. Please advise.

<script language="JavaScript" type="text/javascript">
function addRow(id){
var tbody = document.getElementById
var row = document.createElement("TR")
var td1 = document.createElement("TD")
var td2 = document.createElement("TD")
td2.appendChild (document.createTextNode("5678"))

<a href="#" onclick="addRow('myTable');return false;">Add row</a>
<table id="myTable" cellspacing="0" border="1">


07-12-2004, 07:45 PM
Would you like to elaborate on that a little?

Like what CSS? Have you got some style classes together already or are you asking for our advice as to 'what looks good'?

Or are you asking where/how you would change CSS attributes? This is one we can help you out with:

row.className = 'cssClassName';
row.setAttribute('className', 'cssClassName');
row.style.bgColor = 'blue';

Hope that helps,

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum