How to insert a "th" cell via javascript?

J

Jim

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.
 
M

Martin Honnen

Jim said:
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.
 
D

David Golightly

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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,413
Latest member
ReeceDorri

Latest Threads

Top