How to give anchor tag text and link dynamically using JQuery?

Using below program, we can able to give anchor tag text and link dynamically using JQuery.


<!DOCTYPE>

<html>
<head>
    <title>How to assign anchor tag text and link to the </title>
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
<!--Empty anchor tag -->
<a></a>
<!--This will change to <a href="http://www.jqueryexamplecode.blogspot.com">JQueryExampleCode</a>-->

<script>
    $('a').text('JQueryExampleCode').attr('href', 'http://www.jqueryexamplecode.blogspot.com');
</script>

</body>
</html>


If you have any queries or suggestions,  please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar