-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.js
More file actions
45 lines (33 loc) · 958 Bytes
/
Copy pathnotes.js
File metadata and controls
45 lines (33 loc) · 958 Bytes
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
const content = document.getElementById('content');
const date = document.getElementById('date');
const time = document.getElementById('time');
const addedBtn = document.getElementById('addedBtn');
const deletedBtn = document.getElementById('deletedBtn');
const list = document.getElementById('list');
const listContent = []
function render() {
let htmlStr = ''
listContent.forEach(function (item) {
htmlStr = htmlStr + `
<div class="item">
<div>
<p>內容:${item.content}</p>
<p>時間:${item.date} ${item.time}</p>
</div>
</div>
`
})
list.innerHTML = htmlStr
}
addedBtn.addEventListener('click', function () {
listContent.unshift({
content: content.value,
date: date.value,
time: time.value
})
render()
})
deletedBtn.addEventListener('click', function () {
listContent.shift()
render()
})