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?

27 of 39 people (69%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I change link text dynamically according to the user clicked in Javascript?

Jan 28th, 2003 00:27
Klaus Bolwin, Mat hesh,


If the link has got an ID, you can script the link properties using:
link = document.getElementById(linkid); 
else, you have to create an array, containing the links:
anchors = document.getElementsByTagName("a");
Now, you can get access to the link text using:
link.firstChild.nodeValue
or 
anchors[i].firstChild.nodeValue
in Mozilla/Netscape6+ and all the other Gecko-based browsers
and
link.innerText
or
anchors[i].innerText
in MSIE