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
element.setAttribute(name, value);
The put button onclick="changeHref();"
changeHref function(){
var b = document.querySelector("button"); 

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

April 4th 20 at 00:57
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