There are many ways you could do this. Below I've listed two very simple methods. Here I'm assuming you already have a reference to your a
element (here I've called this element
):
href
attributeelement.href += '?query=value';
element.addEventListener('click', function(event) {
// Stop the link from redirecting
event.preventDefault();
// Redirect instead with JavaScript
window.location.href = element.href + '?query=value';
}, false);