JavaScript link
In this section, you will learn about the text property of Link object in JavaScript.
JavaScript's Link object has the property text which allow the user to get the text value of the link. Here we have used this property with the document.links[0]. To invoke this property from the function, we have created a checkbox, which when clicked, displays the alert box showing the text value of the link.
Here is the code:
| <html> <h2>Text property of the Link object</h2> <script language="JavaScript"> function getText(){ alert(document.links[0].text); } </script> <input type="checkbox" onclick="getText()"> Click the checkbox to get the text value of the link. <a href="http://www.roseindia.net">Welcome to RoseIndia</a> </html> |
Output will be displayed as:
On clicking the checkbox, you will get the text value of link:

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


