aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Add Span Tag to Anchor or inside Hyperlink or href

Jan 2, 2014

Here I will explain how to add span tag to anchor or href or hyperlink using jQuery or jQuery add span tag inside of hyperlink or href.

In previous articles I explained jQuery set maxlength for multiline textbox, jQuery stop form being submit on keypress, jQuery check undefined or empty value and many articles relating to jQuery, JavaScript,, SQL server. Now I will explain how to add span tag in href using jQuery.

To add span tag inside of hyperlink or href we need use prepend property in jQuery for that we need to write the code like as shown below

<title>Add span tag inside of href</title>
<script type="text/javascript" src="//"></script>
<script type="text/javascript">
$(function () {
$('#btnAdd').click(function () {
$('#htitle').prepend(" <span class=spntestclas>Hello </span> there, friend");
<style type="text/css">
.spntestclas {
background: yellow;
<input type="button" id="btnAdd" value="Add Span Tag" />
<a href="#" id="htitle"></a>
Once we run above query we will get output like as shown below

Live Demo

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Ankastre said...

You are very helpful. Jquery is best library in js. Thx

Anonymous said...


Anonymous said...

Nice Post....

Tariq hashmi said...


Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.