Skip to content

Commit f1168d7

Browse files
committed
[day 6] Add unique ID to each list item
1 parent 156a9e2 commit f1168d7

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
@@ -6,7 +6,9 @@ var itemInput = document.getElementById('todo-add-new');
66
var addToDo = function() {
77
var text = itemInput.value;
88
var item = document.createElement("li");
9+
var listLength = list.children.length;
910
item.innerHTML = text;
11+
item.id = "too-doo_" + (listLength + 1);
1012
item.classList.add("todo__item");
1113
list.appendChild(item);
1214
itemInput.value = '';

0 commit comments

Comments
 (0)