I'm trying to create check boxes dynamically. But I have no idea what is the wrong with this code. Somebody please help. Comment if you need more details.
$.getJSON(url, function(json) {
console.log(json);
console.log(json.items.length);
for (var i = 0; i < json.items.length; i++) {
console.log(json.items[i].name);
var checkbox = document.createElement('input');
checkbox.type = "checkbox";
checkbox.name = "name" + json.items[i].name;
checkbox.value = "value";
checkbox.id = "id" + i;
}
});
Thank you
console.log(json.items[i].name);. But after adding checkbox, that log also did not appear.