faqts : Computers : Programming : Languages : JavaScript : Links

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 10 people (80%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I change the text of the link dynamically in Javascript

Dec 13th, 2002 06:30
Klaus Bolwin, Mat hesh,


anchors = document.getElementsByTagName("a");
function changeLink(i, newText)
{
anchors[i].firstChild.nodeValue = newText;
}
or:
<a href="..." onclick="this.firstChild.nodeValue ='new text'">old text</a>