I am trying to create a button remotely to go to a page. I can create the button, I just don't know how to add a "onclick" inside my button.
I have tried to appendChild() of the button, and that doesn't work. I have also tried to make the button an <a>
, that also didn't work.
var btn = document.createElement("button");
var txt = document.createTextNode(name);
var lnk = document.createTextNode("fooPage");
btn.appendChild(txt);
document.body.appendChild(btn);
A button should appear to take the user to a new page (marked by fooPage).