小编O.V*_*ess的帖子

getElementById 不适用于 td 元素

我正在尝试使用 getElementById 访问表元素,但此代码给我“null”作为控制台日志?getElementById 不适用于表吗?

<tr>
  <td id="num1"></td>
  <td id="num2"></td>
  <td id="num3"></td>
  <td id="num4"></td>
  <td id="num5"></td>
</tr>
<script>
  console.log(document.getElementById('num3'));
</script>
Run Code Online (Sandbox Code Playgroud)

html javascript html-table

1
推荐指数
1
解决办法
105
查看次数

标签 统计

html ×1

html-table ×1

javascript ×1