Skip to content

Commit c4bf26d

Browse files
committed
[day 6] Add ability to clear the todos
1 parent afc3cea commit c4bf26d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

projects/6-to-do-list/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ <h1>Too Doo List</h1>
3333
<button id="btn-submit" type="submit">Add to do</button>
3434
</form>
3535
<ul id="todo-items" class="todo-list"></ul>
36+
<a href="#" id="clear-todos">Clear my too doo list</a>
3637
</div>
3738
</div>
3839

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ var validateToDo = function(event) {
3737
}
3838
};
3939

40+
var clearToDos = function(event) {
41+
event.preventDefault();
42+
window.localStorage.clear();
43+
location.reload();
44+
return false;
45+
};
46+
47+
document.getElementById('clear-todos').addEventListener('click', clearToDos, false);
4048

4149
document.getElementById('btn-submit').addEventListener('click', validateToDo, false);
4250

0 commit comments

Comments
 (0)