-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
41 lines (36 loc) · 1.01 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 lang="en">
<head>
<meta charset="UTF-8" />
<title>Simple temperature conversion calculator</title>
<script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.9.1.min.js"></script>
</head>
<body>
<h2>Fahrenheit to Celsius Converter</h2>
<form>
<label for="inputTemp">Input temperature:</label>
<input id="inputTemp" type="text">
<br />
<button id="calcButton" type="button">Convert</button>
</form>
<p>
Temperature in Celsius: <span id="outputTemp">0</span>
</p>
<script>
$(function () {
var
convertToCelsius = function (f) {
return (f - 32) * 5 / 9;
},
onClick = function () {
var
inputTemp = parseFloat($("#inputTemp").val(), 10),
outputTemp = convertToCelsius(inputTemp);
$("#outputTemp").text(outputTemp.toFixed(2));
};
$("#calcButton").on("click", onClick);
$("#inputTemp").focus();
});
</script>
</body>
</html>