I intend to re-use HTML DOM's create element method described in W3Schools for my form.
function myFunction() {
var btn = document.createElement("BUTTON");
var t = document.createTextNode("CLICK ME");
btn.appendChild(t);
document.body.appendChild(btn);
}
<p>Click the button to make a BUTTON element with text.</p>
<button onclick="myFunction()">Try it</button>
In the example above, a button
is used to create a HTML element. How can I change this to use a href link (an <a>
tag) instead of a button's click event?