This code replaces only parts of a string for the first link, but how do I modify this code to take advantage of the click and replace parts of the string for the other links as well, the other links will have different text e.g for “ca-test” it could be anything you want I just want to get this working thanks!
$("#box1").click(function(){
var url = $('.mylink').attr('href')
url = url.replace('us-test', 'replaced-text')
$('.mylink').attr('href', url)
});
<a class="mylink" href="http://google.com/en/get.php?chrome=us-test">Test</a>
<a class="mylink2" href="http://google.com/en/get.php?chrome=ca-test">Test</a>
<a class="mylink3" href="http://google.com/en/get.php?chrome=tk-test">Test</a>
. it not the best solution since it not clear how your page function but maybe it useful for you