【发布时间】:2017-06-21 16:44:06
【问题描述】:
我需要有关动态添加行和列并显示行和列编号的 javascript 代码帮助。动态的。
<!DOCTYPE html>
<html>
<head>
<style>
table, td {
border:1px solid black;
}
</style>
</head>
<body>
<p>Click on each tr element to alert its index position in the table:</p>
<table>
<tr onclick="myFunction(this)">
<td>Click to show rowIndex</td>
</tr>
<tr onclick="myFunction(this)">
<td>Click to show rowIndex</td>
</tr>
<tr onclick="myFunction(this)">
<td>Click to show rowIndex</td>
</tr>
</table>
<script>
function myFunction(x) {
alert("Row index is: " + x.rowIndex);
}
</script>
</body>
这是我尝试过的,但我不确定表的行和列是否是动态生成的,并且列是否没有重新生成和显示。 请帮忙。
【问题讨论】:
-
贴出你试过的代码。
标签: javascript