更新时间:2023-12-03 09:06:52
有很多方法可以做到这一点。下面我列出了两个非常简单的方法。在这里,我假设你已经参考了你的 a
元素(这里我已经调用了这个元素
):
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
):
element.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);