I'm looking to append a query string to the end of a link destination URL upon clicking the link, using jQuery or vanilla JS.
For example say I have this link: <a class="my-link-class" href="/my-url/">click me!</a>
I'd like to do something like:
$(".my-link-class").click(function() {
($this).attr('href').append('?my-string');
});
But this doesn't work, I'm not sure why. I also can't simply add the string directly in my html, as the link destination is dynamic and changes depending on your current url.