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
- Clear cookie example
- JavaScript getElementById innerHTML
- JavaScript getElementById Style
- Javascript Examples
- JavaScript add row dynamically to table
- New Page 1
- JavaScript Change link
- JavaScript Checkbox getElementById
- javascript clear textarea
- JavaScript Clock Timer
- JavaScript Cookies
- JavaScript Date Difference
- JavaScript duplicate string
- JavaScript Email Validation
- javascript focus input
- JavaScript get excel file data
- JavaScript getAttribute Href
- JavaScript getAttribute Style
- JavaScript getElementById div
- JavaScript getElementById Iframe
- JavaScript getElementById select
- JavaScript Hide Button
- JavaScript Hide Div
- JavaScript hide image
- JavaScript Hide Table Column
- JavaScript Hide Table Rows
- JavaScript Key Event
- JavaScript link
- JavaScript method location
- JavaScript move div
- JavaScript move file
- JavaScript move image
- JavaScript Navigate Back
- JavaScript navigate to page
- JavaScript Navigate to URL
- JavaScript indexOf substring
- JavaScript onkeypress event
- JavaScript Open file
- JavaScript Open link in new window
- JavaScript Open Modal Window