-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnote2.js
More file actions
49 lines (40 loc) · 1.24 KB
/
note2.js
File metadata and controls
49 lines (40 loc) · 1.24 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
function addnote(){
var text = document.getElementById("sticky-text").value;
var para = document.createElement("P");
para.setAttribute("id","para");
document.getElementById("txt").appendChild(para);
document.getElementById("para").innerHTML = text;
var del = document.createElement("BUTTON");
del.setAttribute("id","delnote");
del.setAttribute("onclick","rm()");
del.setAttribute("title","Delete this note!");
var x = document.createTextNode("X");
del.appendChild(x);
var edit = document.createElement("BUTTON");
edit.setAttribute("id","editnote");
edit.setAttribute("onclick","edit()");
edit.setAttribute("title","Edit note!");
var e = document.createTextNode("Edit");
edit.appendChild(e);
var btns = document.createElement("DIV");
btns.setAttribute("id","btns");
btns.appendChild(edit);
btns.appendChild(del);
document.body.appendChild(btns);
document.body.appendChild(para);
}
function rm(){
alert("Are you sure?");
document.body.removeChild(para);
document.body.removeChild(btns);
document.getElementById("sticky-text").value = '';
}
var x = 1;
function edit(){
if(x===1){
alert("Type new text in the box and hit Edit again!");
x++;
}
var text2 = document.getElementById("sticky-text").value;
document.getElementById("para").innerHTML = text2;
}