-
Notifications
You must be signed in to change notification settings - Fork 0
/
a.js
27 lines (22 loc) · 694 Bytes
/
a.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var input = document.querySelector("input");
var button = document.querySelector("button");
var ul = document.querySelector("ul");
button.addEventListener("click", buttonfunction);
input.addEventListener("keypress", inputfunction);
function buttonfunction(){
if(input.value.length > 0){
var li = document.createElement("li");
li.onclick = change;
li.appendChild(document.createTextNode(input.value));
ul.appendChild(li);
input.value = "";
}
}
function inputfunction(event){
if(input.value.length > 0 && event.which == 13){
var li = document.createElement("li");
li.appendChild(document.createTextNode(input.value));
ul.appendChild(li);
input.value = "";
}
}