|
Filed Under (Javascript Code Samples) by Anoop on May-16-2007
Code (javascript) <html> <head> <script type="text/javascript"> function changeLink() { document.getElementById('myLink').innerHTML="WebSewak"; document.getElementById('myLink').href="http://www.websewak.com"; document.getElementById('myLink').target="_blank"; } </script> </head> <body> <a id="myLink" href="http://www.yah.in">Yah.in Collection</a> <input type="button" onclick="changeLink()" value="Change link"> </body> </html>
santosh on August 19th, 2008 at 1:14 pm #
Really it is very useful.
Free Quizzes on December 31st, 2008 at 5:31 am #
Yep. Very nice.
Change href, target, text of an anchor tag using Javascript « Huynhvothinh’s Weblog on April 2nd, 2009 at 7:26 am #
[...] href, target, text of an anchor tag using Javascript http://techjunk.websewak.com/change-href-target-text-of-an-anchor-tag-using-javascript/ Code [...]
melanie on April 16th, 2009 at 8:31 pm #
This is really really really helpful. Thank you very much
John Miller on May 12th, 2009 at 2:25 am #
Still helping people! Thanks!
Mark on July 24th, 2009 at 6:48 pm #
why not just: onclick=”this.href=’http://whateverurl’” ?
Affiliate Tracking on September 17th, 2009 at 3:55 pm #
With jquery (http://jquery.com) you could make it with a single line of code :) Post a comment
|
|