forked from iDTech-Neha/iDTech_JavaScript_Coding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertDOM.html
More file actions
25 lines (24 loc) · 827 Bytes
/
insertDOM.html
File metadata and controls
25 lines (24 loc) · 827 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
<!DOCTYPE html>
<html>
<head>
<script>
function addParagraph(){
const story = document.getElementById("myinput").value;
const textNode = document.createTextNode(story);
const newPTag = document.createElement("p");
newPTag.appendChild(textNode);
const pList = document.getElementById("WriteStory");
pList.appendChild(newPTag);
document.getElementById("myinput").value = "";
}
</script>
</head>
<body>
<div>
<h1>My Story!</h1>
<textarea id="myinput"></textarea>
<button onclick = "addParagraph()">Add</button>
</div>
<div id="WriteStory"></div>
</body>
</html>