Questions:Ask|Latest


 
 

Share on Google+Share on Google+

JavaScript link

Advertisement
This page discusses - JavaScript link

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:

Download Source Code:

        

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 18, 2011

Ask Questions?    Discuss: JavaScript link  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com