为什么可以't我使用在另一个地方使用Javascript使用的相同代码更新此表

Why can't I update this table with the same code used in another place using Javascript?

本文关键字:Javascript 方使用 更新 代码 为什么 另一个      更新时间:2023-09-26

表格单元格在changeScore函数中正确更新为"(空),但当我尝试将新分数放入editUpdate函数时,该单元格在其中根本不会更改。它只是空着。有什么想法吗?

function changeScore(playerKey)
{
    var table = document.getElementById("scoreTable");
    players[playerKey].score = players[playerKey].oldScore;
    table.rows[currentRound - 1].cells[playerKey + 1].innerHTM = '';
    document.getElementById('inputArea').innerHTML = '<font size="6">Did <b>' + players[playerKey].name + '</b> take <b>' + players[playerKey].bid + '</b> trick(s)?</font><br /><button value="Yes" id="yesButton" onclick="editUpdate(' + playerKey + ', ''yes'')">Yes</button>&nbsp&nbsp&nbsp&nbsp<button value="No" id="noButton" onclick="editUpdate(' + playerKey + ', ''no'')">No</button>';
}
function editUpdate(thePlayerKey, answer)
{
    var table = document.getElementById("scoreTable");
    players[thePlayerKey].oldScore = players[thePlayerKey].score;
    if (answer == "yes"){
        **
    }else{
        **
    }
    table.rows[currentRound - 1].cells[thePlayerKey + 1].innerHTM = '<font color="' + players[thePlayerKey].font + '">' + players[thePlayerKey].score + '</font>';
    document.getElementById('inputArea').innerHTML = '<button onclick="startRound()">Start Round</button>&nbsp&nbsp&nbsp&nbsp&nbsp<button onclick="edit()">Edit Scores</button>';
}

innerHTM应为innerHTML

此:

table.rows[currentRound - 1].cells[playerKey + 1].innerHTM = '';

应为:

table.rows[currentRound - 1].cells[playerKey + 1].innerHTML = '';

(与第二个函数相同)