Change href, target, text of an anchor tag using Javascript

http://techjunk.websewak.com/change-href-target-text-of-an-anchor-tag-using-javascript/

Code (javascript)

<html>
<head>
<script type=“text/javascript”>
function changeLink()
{

        document.getElementById(‘myLink’).innerHTML=“WebSewak”;
        document.getElementById(‘myLink’).href=http://www.websewak.com&#8221;;

        document.getElementById(‘myLink’).target=“_blank”;
}

</script>
</head>
<body>

<a id=“myLink” href=http://www.yah.in&#8221;>Yah.in Collection</a>

<input type=“button” onclick=“changeLink()” value=“Change link”>

</body>
</html>
 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s