Temperature Converter
Converts the temperature from Celsius to Fahrenheit and vice versa.
by rbrousla
HTML
<input type="text" class="inputFahrenheit">
<button class="button1">Enter</button>
</input>
<p>Enter the temperature in Fahrenheit</p>
<p>
<input type="text" class="inputCelsius">
<button class="button2">Enter</button>
</input>
</p>
<p>Enter the temperature in Celsius</p>
<p class="fahrenheit"></p>
<p class="celsius"></p>
JavaScript
$(document).ready(function () {
$(".button1").click(function () {
var x = parseInt($(".inputFahrenheit").val());
var y = (x - 32) * (5 / 9);
$(".fahrenheit").html(y.toFixed(1) + " degrees Celsius");
});
$(".button2").click(function () {
var a = parseInt($(".inputCelsius").val());
var b = (a * (9 / 5)) + 32;
$(".celsius").html(b.toFixed(1) + " degrees Fahrenheit");
});
});