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
- 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


