html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
</head>
<body>
<div class="container">
<h2>Tip calculator</h2>
<p>Enter amount:</p>
<input id="amount" type="text">
<button class="submit" onclick="tip()">Submit</button>
<div id="show-container"></div>
</div>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
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
body {
text-align: center;
font-family: Raleway;
margin:0;
padding-top: 40px;
}
.container {
background-color: white;
border: 1px solid black;
border-radius: 1%;
box-shadow: 10px 5px #F2F3F4;
width: 250px;
height: 200px;
margin: 0 auto;
}
.submit{
border: 1px solid black;
background-color: #FFFFFF;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
var tip = function(){
var amount = document.getElementById("amount").value;
var tipTotal = amount * 0.15; document.getElementById("show-container").innerText = "Your tip should be $"+tipTotal.toFixed(2)+ " at 15%";
document.getElementById("amount").value = null;
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run