-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
20 lines (20 loc) · 820 Bytes
/
Copy pathindex.js
File metadata and controls
20 lines (20 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function addComment() {
var nameInput = document.getElementById("nameInput");
var commentInput = document.getElementById("commentInput");
var commentsDiv = document.getElementById("comments");
var name = nameInput.value;
var commentText = commentInput.value;
if (name.trim() !== "" && commentText.trim() !== "") {
var newComment = document.createElement("div");
newComment.classList.add("comment");
var namePara = document.createElement("p");
namePara.innerHTML = "<strong>" + name + "</strong>";
newComment.appendChild(namePara);
var commentPara = document.createElement("p");
commentPara.textContent = commentText;
newComment.appendChild(commentPara);
commentsDiv.appendChild(newComment);
nameInput.value = "";
commentInput.value = "";
}
}