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>
data-attribute in the html for each link or somewhere in your JS code. (Also, I think you should be using theidattribute rather than theclassattribute since your class names seem like unique identifiers.)