Forum Moderators: open
im trying to add a class name in a exsisting TD tag of a HTML table.
this code doesnt print any errors but dont add the class either...
<SCRIPT>
function changeclass() {
var NAME = document.getElementsByTagName("TD")
NAME.className="items"
}
</SCRIPT><a href="#" onclick="changeclass();">TEST</a>
and this is my table sample wich have no class asigned, it is waiting for the script who is supposed will add it a neww class
<style>
TD.items {COLOR: 000;}
TD.items A:link {COLOR: blue; font-weight: bold;}
TD.items A:visited {COLOR: blue; font-weight: bold;}
TD.items A:active {COLOR: blue; font-weight: bold;}
TD.items A:hover {COLOR: #505C6D; font-weight: bold;}
</style>
<table>
<tr>
<td><a href="http://somewhere.com"><b>my custom text</a></td>
</tr>
</table> any help will be apreciated
thanks
See:http://www.webmasterworld.com/forum91/3730.htm
It's probably easier in your case to switch the class of the table, and getthe effect by using a descendant selector in the stylesheet.
-----
Unless you mean that there's only one TD in the whole document:
document.getElementsByTagName('td')[0].className = 'foo';
thanks... after read your post i understand a couple things..
it was fiexed by adding a for loop base in the concept of may td's
thnaks