-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
41 lines (38 loc) · 1.71 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Kaylee's Personal Website</title>
<!-- Link to css files if needed -->
<link rel="stylesheet" type="text/css" href="css/index.css">
</head>
<body>
<h1>My Name is Name</h1>
<h1>This is a first level heading in HTML.</h1>
<h2>This is a second level heading in HTML.</h2>
<h3>This is a third level heading in HTML.</h3>
<p>This is a <em>paragragh</em> As you can see, I placed an empahisis on the word "paragraph".</p>
<p>Portfolio Workshop:</p>
<ul>
<li>How to format a web document with HTML</li>
<li>How to design a web page with CSS</li>
<li>How to program a web document with JavaScript</li>
</ul>
<p>Next, I am going to add the following two numbers and display the result, all with JavaScript<p/>
<p>First number: <span id= "firstNum">2</span> <br></p>
<p>Second number: <span id= "secondNum">7</span> </p>
<p>Therefore, the sum of the two of those numbers is: <span id= "answer">(placeholder for the answer)</span></p>
<input type="button" id="sumButton" value="Click to add!">
<script type="text/javascript">
function displaySum() {
// getElementById will get all HTML elements by a specific "id" attribute
let firstNum = Number(document.getElementById('firstNum').innerHTML)
let secondNum = Number(document.getElementById('secondNum').innerHTML)
let total = firstNum + secondNum;
document.getElementById("answer").innerHTML = ` ${firstNum} + ${secondNum}, equals to ${total}` ;
}
document.getElementById('sumButton').addEventListener("click",displaySum);
</script>
</body>
</html>