Posted in jquery
3
12:17 am, June 28, 2019

Change link target with JQuery

this will change the link href target to # on document load rather than its original link

HTML

<div class='nested-link alert'>
<a href='the.link.to.replace' class='btn btn-primary'>link target</a>
</div>

Javascript

$(document).ready(function() {
$('.nested-link > a').attr("href", "#");
}

View Statistics
This Week
10
This Month
76
This Year
0

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

Join me on Substack if you want me to send you a collection of the things i have done or found or read for the week. Or follow me on twitter if you prefer, i dont post much but i probably should!

❤👩‍💻🕹

Random Quote
The problem with hoarding is you end up living off your reserves. Eventually, you’ll become stale. If you give away everything you have, you are left with nothing. This forces you to look, to be aware, to replenish. . . . Somehow the more you give away, the more comes back to you.
Paul Arden