We can create a <button> element via the document.createElement()
method:
var x = document.createElement("BUTTON");
Click the button to create a BUTTON element with a "Click me" text.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from w ww. ja v a 2 s. c om var x = document.createElement("BUTTON"); var t = document.createTextNode("Click me"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>