Can someone assist with the below code?
var createTodo = function(todo) {
// write your code here;
var list = document.getElementById('todoList');
var li = document.createElement('li');
var input = document.createElement('input');
input.setAttribute('type','checkbox');
var label = document.createElement('label');
input.innerHTML = todo;
var button = document.createElement('button');
button.setAttribute('class','delete');
list.appendChild(li);
list.appendChild(input);
list.appendChild(label);
list.appendChild(button);
}
I figured it out, but i cant figure out what 4th child it wants???
var createTodo = function(todo) {
// Define Parent
var td = document.getElementById('todoList');
// Creating the elements
var li = document.createElement('li');
// Child Elements of LI
var input = document.createElement('input');
var label = document.createElement('label');
var button = document.createElement('button');
// Assign the elements types if needed
input.setAttribute('type','checkbox');
button.setAttribute('class','delete');
button.innerHTML= "Delete";
label.innerHTML = todo;
// Append elements to child
li.appendChild(input);
li.appendChild(label);
li.appendChild(button);
td.appendChild(li);
return li;
}
The image on the course only lists LI and 3 children…