When you use your local variable
temp
, you are referencing the DOM element. However you are trying to use it as if it was the numeric value of the
innerHTML
. So either use
temp = document.getElementById("temperature").innerHTML;
in your onload function, or tack on
.innerHTML
where you reference it.