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: