-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
57 lines (38 loc) · 1.37 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
const addButton = document.getElementById('add');
const addnewNotes = (text = '') =>{
const note = document.createElement('div');
note.classList.add('note');
const htmlData = `
<div class="note1">
<button class="edit"><i class="fas fa-pen"></i></button>
<button class="delete"><i class="fas fa-trash-alt"></i></button>
<div class="main ${text ? "" : "hidden"} ">
<textarea class=" ${text ? "hidden" : ""} " rows="7" cols="35" placeholder="Enter your notes..."></textarea>
</div> `;
note.insertAdjacentHTML('afterbegin',htmlData);
// getting the refenceses
const Buttondel = note.querySelector('.delete');
const Buttonedit = note.querySelector('.edit');
const mainDiv = note.querySelector('.main');
const textarea = note.querySelector('textarea');
//deleting node
Buttondel.addEventListener('click',()=>{
note.remove();
})
//toggle using edit button
// textarea.value = text;
// mainDiv.innerHTML = text;
// Buttonedit.addEventListener('click',()=>{
// mainDiv.classList.toggle('hidden');
// textarea.classList.toggle('hidden');
// });
// textarea.addEventListener('chage',(event)=>{(
// Buttondel.addEventListener
// )};
// textarea.addEventListener('change',(event)=>{
// const value = event.target.value;
// console.log(value);
// })
document.body.appendChild(note);
}
addButton.addEventListener('click', () => addnewNotes() );