forked from lee2sman/chirp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
77 lines (58 loc) · 1.92 KB
/
index.html
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
<title>
CHIRP
</title>
</head>
<body>
<div class="grid-container">
<div class="left-col">
<p>
<input type="text" placeholder="Enter chirp" id="textInput">
</p>
<button class="my-button" onclick="addDiv()">Add a chirp</button>
<p>
<input type="text" placeholder="Image url" id="imgInput">
</p>
<button class="my-button" onclick="addImage()">Add an image</button>
</div>
<div class="right-col" id="content-area">
</div>
</div>
<script>
function addDiv() {
//create a new P tag, save it in a variable
let theNewDiv = document.createElement("div");
//add a class to our new div element
theNewDiv.classList.add("auto-div");
//set the text inside the div
theNewDiv.innerHTML = document.getElementById("textInput").value;
//find the right tag to add the div to
//we used an id of "content-area" for
//the place where we want to add the chirp
let theContentArea = document.getElementById("content-area");
//add the new div to that tag
theContentArea.appendChild(theNewDiv);
}
function addImage() {
//create a new P tag, save it in a variable
let theNewDiv = document.createElement("div");
//add a class to our new div element
theNewDiv.classList.add("auto-div");
//create image tag to put into the div
theImgTag = "<img src='" + document.getElementById("imgInput").value + "' width = 100 height = 100>";
//set the text inside the div
theNewDiv.innerHTML = theImgTag;
//find the right tag to add the div to
//we used an id of "content-area" for
//the place where we want to add the twit
let theContentArea = document.getElementById("content-area");
//add the new div to that tag
theContentArea.appendChild(theNewDiv);
}
</script>
</body>
</html>