Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

button in vanilla js

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.");
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #button #vanilla #js
ADD COMMENT
Topic
Name
4+2 =