I have a table that looks like:
<table id="myTable">
<col id="name" />
<col id="birthYear" />
<col id="phone" />
<td>
<tr>Joe</tr>
<tr>1972</tr>
<tr>202-555-1234</tr>
</td>
</table>
Is there an easy way to get an array of the <col />
tags? I don't want to use getElementById because I don't know the ids of the col tags, although I will know the Id of the table. I don't want to use getElementsByTagName because there will be several tables in the document with col tags.
I'm not using jquery, just regular javascript.
Any ideas?
getElementsByTagName can be used on table with id "myTable" : it will returns all col of this table.
here is an example :
document.getElementById("myTable").getElementsByTagName("col")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With