Jquery Add Href attribute to Link

To append Href attribute in existing link follow below Jquery

Link :

<a class=”hclass” ><img src=”/images/link.png” id=”htest” border=”0″ alt=””/>Google</a>

Jquery Script :

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js”></script&gt;
<script>
$(document).ready(function(){

$(‘#htest’).attr(‘href’,’https://www.google.co.in/&#8217;);

});
</script>

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 )

Connecting to %s