Skip to content

Commit 4100a1b

Browse files
committed
[day 6] Add unique id to each todo item
1 parent 8613b41 commit 4100a1b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

projects/6-to-do-list/js/to-do.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ var newToDo = document.getElementById('todo-add-new');
55
var addToDo = function() {
66
var txt = document.createTextNode(newToDo.value);
77
var item = document.createElement("li");
8+
var count = toDoList.children.length;
89

910
if(newToDo.value) {
1011
item.appendChild(txt);
12+
item.id = "todo-item-" + (count + 1);
1113
toDoList.appendChild(item);
1214
newToDo.value = "";
1315
};

0 commit comments

Comments
 (0)