溫度從xml中拉入。我需要在頁面加載後轉換此數字並替換原始數字。通過getElementsByClassName獲取溫度轉換爲攝氏溫度取代原始溫度
<td class="weathertemperature temperatureplus">26</td>
function convert() {
F = document.getElementsByClassName("weathertemperature").value * 9/5 + 32;
document.getElementsByClassName("weathertemperature").value = Math.round(F);
}
convert();
當我調試警報(F);我得到NaN
.textContent工作得好多了,謝謝! – user2882684