小编use*_*483的帖子

在Javascript中将图像插入表格单元格

我想将图像插入刚创建的新单元格.我该怎么做?任何人都可以指导我这样做吗?这是我的insertcells代码:

<!DOCTYPE html>
<html>
<head>
<script>
function displayResult()
{
var firstRow=document.getElementById("myTable").rows[0];
var x=firstRow.insertCell(-1);
x.innerHTML="New cell"
}
</script>
</head>
<body>

<table id="myTable" border="1">
  <tr>
    <td>First cell</td>
    <td>Second cell</td>
    <td>Third cell</td>
  </tr>
</table>
<br>
<button type="button" onclick="displayResult()">Insert cell</button>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我想要的只是在创建的单元格中插入图像.

html javascript html-table image cell

7
推荐指数
3
解决办法
4万
查看次数

标签 统计

cell ×1

html ×1

html-table ×1

image ×1

javascript ×1