Javascript to-do list -2
- diffference between element.childnodes and element.children :
chindnodes will return every contained element in nodelist[]. it will even return comments and texts.
children will return only html elements present in it in HTMLCollection[].
- forEach loop in JS:
if we want to loop over every element in array.
eg-
const todos=todoList.childNodes;
todos.forEach(function(todo){
})
here, todo is refered to each element in array todos.
- todo.classList.contains('completed'): checks if element todo has a class 'completed'.
- todo.classList.toggle('completed') : toggle the class 'completed' over the element todo.
still need to work on local storage. will post it later.
Comments
Post a Comment