javascript - How do I use URL parameters to change link href on page? -
i change href value of link using url parameters.
example:
default <a id="dlink" href="link-1">link</a>
but, when user goes https://url.com/?dlink=link-2
it swaps out link
new link <a id="dlink" href="link-2">link</a>
first need value url. if you're not using javascript framework can create function using jquery.
please check get url parameter jquery or how query string values in js it.
after that, element "a" id , set value there.
$("#dlink").attr("href", hreffromparam);
Comments
Post a Comment