Hey guys, so I’ve been trying to make a Fahrenheit to celsius converter page. But I think I’ve run aground with this one. I think something is wrong with what I did with my JS. But I’m not sure about what I messed up? Any help would be appreciated!
Thanks in advance!
Regards
Ma3_str0
My HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Fahrenheit to Celsius Converter</title>
<script src="app.js"></script>
<link href="styles.css" rel="stylesheet">
</head>
<body>
<!--intro and basic description of page-->
<header>
<h1 id="title">Fahrenheit to Celsius Converter</h1>
<h2>Please enter the amount of Fahrenheit you want to convert</h2>
</header>
<!-- the main attraction of the page-->
<main>
<div id="main-attraction">
<div id="inputs">
<label for="num-input">Please enter the amount of Fahrenheit here:</label>
<input type="number" name="num-input">
</div>
<div id="output-button"><button onclick="calc()">Click here to convert</button></div>
<div id="output-display">Result:</div>
</div>
</main>
<!--ending of page-->
<footer>
<p id="footer-text">Made by Ma3_str0 in 2020</p>
</footer>
</body>
</html>
My CSS:
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@900&display=swap');
body{
background-image: url("https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse2.mm.bing.net%2Fth%3Fid%3DOIP.FSShteIpNjKrqBJXllt2IAHaEK%26pid%3DApi&f=1");
background-repeat: no-repeat;
background-size: cover;
font-family: 'Montserrat', sans-serif;
}
header{
text-align: center;
background-color: white;
padding:10px;
margin-left: 200px;
margin-right: 200px;
}
#main-attraction{
margin-left: 300px;
margin-right: 300px;
background-color: white;
margin-top: 205px;
text-align: center;
}
button{
font-size: large;
font-weight: 200;
}
#output-button{
padding:6px;
margin-top:10px;
margin-bottom:15px;
text-align: left;
}
#inputs{
padding:6px;
margin-top:10px;
text-align: left;
}
#output-display{
color:white;
}
footer{
text-align: center;
margin-top: 150px;
background-color: white;
font-size: x-large;
padding:10px;
margin-left: 200px;
margin-right: 200px;
text-decoration: wavy;
}
My JS:
let outputDisplay = document.getElementById("output-display");
let inputNum = document.getElementById("num-input");
function calc(num){
let celsius = (num - 32)/1.8;
outputDisplay.style.color("black");
return outputDisplay.innerHTML = celsius;
}
calc(inputNum);