javascript add button to div

Solutions on MaxInterview for javascript add button to div by the best coders in the world

showing results for - "javascript add button to div"
Melodie
11 Jan 2017
1// get the element you want to add the button to
2var myDiv = document.getElementById("demo");
3
4// create the button object and add the text to it
5var button = document.createElement("BUTTON");
6button.innerHTML = "Button";
7
8// add the button to the div
9myDiv.appendChild(button);