JavaScript Change link's text
In this section, you will learn how to change the link's text in JavaScript.
The modification of HTML code is quite simple. Now to modify the link's text, we have created a link that dynamically changes when you pass the mouse pointer over it. The JavaScript property innerHtml allows you to change your text. Therefore when you pass the mouse over the text link, the onMouseOver event occurs which shows the text 'RoseIndia' and when you release the mouse, onMouseOut event occurs which changes the text to 'Java Tutorials'.
Here is the code:
| <html> <h2>Change Link's Text</h2> <a href="http://www.roseindia.net"> <div onMouseOver="this.innerHTML = 'RoseIndia'" onMouseOut="this.innerHTML = 'Java Tutorials'">Java Tutorials</div></a> </html> |
Output will be displayed as:
On passing the mouse pointer over the link, it will change the text:

Tutorials
- Java 26 (JDK 26) Features with examples
- Top 10 Reasons to Learn Java in 2026
- JDK 26 Tutorial
- Java Certification Roadmap 2026: Which Oracle Certs Matter
- Install JDK 26: A Complete Beginner's Guide (2026)
- What Is Java? A Complete, Up-to-Date Guide for 2026
- Java 26 HTTP3 tutorial - HTTP 3 support in JDK 26 - How to use HTTP/3 in Java 26 application?
- JDK 28 Preview: Value Objects, Shenandoah GC & JSON API
- Java Tutorials


