When I click the button, it doesn't run the onclick. I tried it in the console and it worked fine. Can anyone help?
function customAlert(message) {
sect = document.createElement("section");
sect.className = "alert";
sect.innerHTML = message + "<br /><br />";
var but = document.createElement("button");
but.innerHTML = "Gotcha.";
but.onclick = "document.body.removeChild(sect);";
sect.appendChild(but);
document.body.appendChild(sect);
}
<button onclick="somestring">. But it will be executed in the global scope.