Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to insert a "th" cell via javascript?

2,699 views
Skip to first unread message

Jim

unread,
Aug 15, 2007, 9:15:57 AM8/15/07
to
I've found the insertcell method of the document, but I'd like to build
something of the form:

<table>
<tr>
<th>
</th>
<th>
</th>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>

There appear to be no options on the insertcell method. Is there
another way to specify that the rows be "th" rows?

Thanks,
Jim.

Martin Honnen

unread,
Aug 15, 2007, 9:20:53 AM8/15/07
to
Jim wrote:

> There appear to be no options on the insertcell method. Is there
> another way to specify that the rows be "th" rows?

Use
var th = document.createElement('th');
then you can use insertBefore or appendChild to insert the th cell into
a tr row element.


--

Martin Honnen
http://JavaScript.FAQTs.com/

David Golightly

unread,
Aug 15, 2007, 12:30:49 PM8/15/07
to

Also, you won't get very far in IE unless you wrap your <tr> tags in
<thead> and/or <tbody>. In spite of the HTML 4 spec, I usually
reserve <th> for row headings, using <td> tags in a <thead> for column
headings. But now I'm getting into an HTML discussion, which is OT
for this list.

0 new messages