-
Notifications
You must be signed in to change notification settings - Fork 1
/
todo3.js
28 lines (25 loc) · 883 Bytes
/
todo3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var Edit = document.getElementById("edit");
var TodoList = document.getElementById("text-holder");
var InputText = document.querySelector('input');
var span = document.querySelectorAll('span');
Edit.addEventListener('click', function () {
InputText.style.display = "block";
});
InputText.addEventListener('keypress', function (event) {
if (event.keyCode == 13 && event.target.value != '') {
var li = document.createElement('li');
var span = document.createElement('span');
span.innerHTML = '× ';
span.addEventListener('click', function () {
this.parentElement.remove();
});
li.append(span);
li.append(event.target.value);
TodoList.append(li)
}
});
for (var i = 0; i < span.length; i++) {
span[i].addEventListener('click', function () {
this.parentElement.remove();
});
}