PDA

View Full Version : Change class of text inside a TD


freddybee
12-25-2002, 10:59 PM
I do have a table with TD like this

<TD id="td1" onclick="CallMe();"><A Class="C1" HREF="...">Text</A></TD>

When the user click on the cell, the onclick is fired and the CallMe function is called ...
I want to change the Class of the anchor in the function ...

I have tried eval(getElementById("td1").children.className="C2") ... with no success

Do you know why and how to achieve my "strange" pb

Thanks in advance and merry xmas..
:thumbsup:

Adam20002
12-25-2002, 11:26 PM
Hi Freddy

I would think the easiest thing to do would be to give the anchor tag an id and then call getElementById on that id.


document.getElementById("a1").className = "newClass";


Adam

freddybee
12-25-2002, 11:41 PM
You are right .... the name of the anchor depends on the parent but it could be passed as a variable ...

Thanks