Click to See Complete Forum and Search --> : DOM: get <td> element


dummyagain
July 17th, 2007, 01:13 AM
i get something like this

<td class=abc>test</td>
<td><input class=cde name=box></td>

i would like to know how to use dom to change the class name "abc" or any other way to do it? (except assign an id to it)

Thank you

andreasblixt
July 17th, 2007, 02:16 AM
// Instead of using the document object below, you can also get the table and use the getElementsByTagName method on that to limit the scope to that one table.
var tds = document.getElementsByTagName("TD");
for (var i = 0; i < tds.length; i++) {
var td = tds[i];
if (td.className == "abc") td.className = "def";
}