📅  最后修改于: 2022-03-11 15:02:57.633000             🧑  作者: Mango
let newButton = document.createElement('button');
newButton.setAttribute("id", "myNewButton");
newButton.className = "myClassName";
newButton.innerText = "clickMe";
newButton.addEventListener("click", clickMe);
document.body.appendChild(newButton);
function clickMe(){
console.log("Hi! I am a new Button.");
}