-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
79 lines (69 loc) · 2.28 KB
/
script.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<<<<<<< HEAD
const formInput = document.getElementById("item-form");
const button = document.getElementById(".btn");
const textInput = document.getElementById("item-input");
const itemList = document.getElementById("item-list");
function onSubmit(e){
e.preventDefault();
const newInputValue = textInput.value
if(newInputValue === ''){
alert('Please add an item');
return;
}
const form = new FormData(formInput);
const newList = document.createElement('li');
newList.appendChild(document.createTextNode(newInputValue));
const newButton = createButton("remove-item btn-link text-red");
newList.appendChild(newButton);
itemList.appendChild(newList)
textInput = '';
console.log('success');
}
function createButton(classes){
const newButton = document.createElement('button');
newButton.className = classes;
newButton.appendChild(createIcon('fa-solid fa-xmark'));
return newButton;
}
function createIcon(classes){
const v = document.createElement('i');
v.className = classes;
return v;
}
// Event Listeners
formInput.addEventListener('submit', onSubmit);
=======
const formInput = document.getElementById("item-form");
const button = document.getElementById(".btn");
const textInput = document.getElementById("item-input");
const itemList = document.getElementById("item-list");
function onSubmit(e){
e.preventDefault();
const newInputValue = textInput.value
if(newInputValue === ''){
alert('Please add an item');
return;
}
const form = new FormData(formInput);
const newList = document.createElement('li');
newList.appendChild(document.createTextNode(newInputValue));
const newButton = createButton("remove-item btn-link text-red");
newList.appendChild(newButton);
itemList.appendChild(newList)
textInput = '';
console.log('success');
}
function createButton(classes){
const newButton = document.createElement('button');
newButton.className = classes;
newButton.appendChild(createIcon('fa-solid fa-xmark'));
return newButton;
}
function createIcon(classes){
const v = document.createElement('i');
v.className = classes;
return v;
}
// Event Listeners
formInput.addEventListener('submit', onSubmit);
>>>>>>> df7d92c1350cb082e8070a96a87b2456e840fd8c