我正在为网络应用制作排行榜,我需要更改td值。
我尝试使用.addEventListener,document.getElementById,并且只是更改了值。
<tr>
<td id= "name" class= "beggin">---</td>
<td id= "games">---</td>
<td id= "w/l">---</td>
<td id= "win">---</td>
<td id= "loss" class= "end">---</td>
</tr>
name
<input id= "debug-name" type="text">
<br>
<script>
//grabs debug strs and loads into console
const debugName = document.querySelector('#debug-name')
function debugNameLog(e){
console.log(debugName.value)
}
debugName.addEventListener("change", debugNameLog);
//puts debug name into td class name
const tdName = document.querySelector('.name')
function debugNameTd(e){
debugName.innerHTML = this.value;
}
tdName.addEventListener("change", ".name", debugNameTd);
//tdName.value = debugName.value
//document.getElementById("name").innerHtml = debugName
</script>
期望的输出是输入的文本,td id =“ name”