We can create an <input> element with type="checkbox" via document.createElement()
method:
var x = document.createElement("INPUT"); x.setAttribute("type", "checkbox");
Click the button to create a Checkbox.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from w w w . java 2s. c o m*/ var x = document.createElement("INPUT"); x.setAttribute("type", "checkbox"); document.body.appendChild(x); } </script> </body> </html>