button in vanilla js

Solutions on MaxInterview for button in vanilla js by the best coders in the world

showing results for - "button in vanilla js"
Gael
28 Nov 2019
1let newButton = document.createElement('button');
2newButton.setAttribute("id", "myNewButton");
3newButton.className = "myClassName";
4newButton.innerText = "clickMe";
5newButton.addEventListener("click", clickMe);
6document.body.appendChild(newButton);
7function clickMe(){
8    console.log("Hi! I  am a new Button.");
9}