I'm trying to append query parameters to links within blocks of text within a class, such as
<div class="container">
consectetur <a href="foo.php?q=bar">adipisicing</a>
</div>
where the ?q=bar is appended. Here's my function:
function appendRef(container,reftag) {
var Link = $(container).attr("href");
var afterLink = reftag;
$(container).attr({
href: (Link + afterLink)
});
}
appendRef(".container a", "?q=bar");
However, this converts every link within the div to the values returned by the first one it sees, rather than processing them uniquely. I'm also looking to be able to filter the function based on part of the original url. Something like
if Link.match(/domain/) { //append the param
}