Work with href button?

How to make that on button click it was possible to change the href of the tag a
April 4th 20 at 00:53
2 answers
April 4th 20 at 00:55
Solution
element.setAttribute(name, value);
The put button onclick="changeHref();"
changeHref function(){
var b = document.querySelector("button"); 

b.setAttribute("disabled", "disabled")
} // example

Here
April 4th 20 at 00:57
Solution
const youButton = document.querySelector("YOU_BUTTON_SELECTOR");
const youLink = document.querySelector("YOU_LINK_SELECTOR");

youButton.addEventListener("click", e => {
 youLink.href = "New Value";
});

Find more questions by tags JavaScript