I try the follow -
var input = document.createElement("<input type='checkbox' name='test'>")
but it prompt -
Uncaught InvalidCharacterError: The string contains invalid characters.
I use Chrome Version 33.0.1750.146 m
I try the follow -
var input = document.createElement("<input type='checkbox' name='test'>")
but it prompt -
Uncaught InvalidCharacterError: The string contains invalid characters.
I use Chrome Version 33.0.1750.146 m
You create the plain element and then add the attributes:
var input = document.createElement("input");
input.type = "checkbox";
input.name = "test";
The document.createElement function takes a tag name for the element you want to create (in your case input)
var input = document.createElement("input");
you can then access attributes for that element like so:
input.type = "checkbox";
input.name = "test";
Here is another question with the same answer: How to create <input type=“text”/> dynamically