forked from codemistic/Web-Development
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
49 lines (41 loc) · 1.31 KB
/
app.js
File metadata and controls
49 lines (41 loc) · 1.31 KB
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
// localStorage.clear();
const addBtn = document.getElementById('addBtn');
const cardno = document.getElementById('cardno');
let textarea = document.getElementById('text');
let counter=0;
addBtn.addEventListener('click',getdata);
function getdata(){
let notevalue = textarea.value; //Getting the data what user entered
let localnotes = localStorage.getItem('notes');
if(localnotes == null){
notesarr = [];
}
else{
notesarr = JSON.parse(localnotes);
}
notesarr.push(notevalue);
localStorage.setItem("notes",JSON.stringify(notesarr));
textarea.value='';
shownotes();
}
function shownotes(){
let localnotes = localStorage.getItem('notes');
if(localnotes == null){
notesarr = [];
}
else{
notesarr = JSON.parse(localnotes);
}
cardno.classList.remove('hide');
let html = "";
notesarr.forEach(function(element,index){
html += `<div class="card hide" id="cardno">
<div class="card-content">
<h3 id="heading"></h3>
<p id="paragraph"></p>
</div>
</div>`;
});
let notes = document.getElementById('notes');
notes.innerHTML = html;
}