0
我需要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>
這是我已經試過,但我不知道是否該表格的行和列是動態生成的,也列不renerated和顯示。 請幫忙。
發佈您嘗試的代碼。 –