📌  相关文章
📜  vanilla js中的按钮 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:57.633000             🧑  作者: Mango

代码示例1
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.");
}