I need a way of replacing the text contained within <a href="this text"
using jQuery, I want to replace what ever text is held within quotes to a '#'
.
Any suggestions?
$('a').attr('href', '#');
...
$(function(){
$('a').attr('href', '#');
});
The ready
handler should take care of changing the href
of your links when the page loads.
If you have link(s) with some class or id set to them, you can simply do:
$(function(){
$('a.link_class').attr('href', '#');
// $('#some_id').attr('href', '#'); // for id
});
If you want to do it with some button click, etc, you can do like:
$('#button_id').click(function(){
$('a').attr('href', '#');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With