-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
29 lines (25 loc) · 900 Bytes
/
main.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
const addPost = () => {
// get the text from the input
const input = document.getElementById('postInput')
const postText = input.value
// alert(postText)
// make new post elements
// make a div
const tweetDiv = document.createElement('div')
tweetDiv.className = 'tweet'
// make an h2 w/ Username as its content
const username = document.createElement('h2')
username.innerHTML = "Username"
// make a p tag with the post text from the input as its content
const postContent = document.createElement('p')
postContent.innerHTML = postText
// add a like button
const likeButton = document.createElement('button')
likeButton.innerHTML = "like"
tweetDiv.appendChild(username)
tweetDiv.appendChild(postContent)
tweetDiv.appendChild(likeButton)
// append to the DOM
const container = document.getElementById('postContainer')
container.appendChild(tweetDiv)
}