Monday, November 12, 2007

Change text link in Javascript

How to change a link text in Javascript



Let's say you have a link, with the anchor text 'mylink', and you want to change this text using Javascript. For this we will use innerHTML attribute. Here it is:

document.getElementByID( 'mylinkid' ).innerHTML = 'my new link text';

You will probably need this if youn need to show/hide some html elements.


Changing text in a link using Javascript

No comments: