「http://stackoverflow.com/questions/9045940/dynamically-adding-table-row」を参照してテーブルを作成しました。テーブルの最後の行に入ったときはいつでも、別の行をテーブルに追加する必要があります動的に下に、ここに私が試したコードがあります:
<table id="myTable" style="table-layout:auto">
<tr>
<td><input type="text" onblur="addRow('myTable')" /></td>
<td><input type="text"/></td>
<td><input type="text"/></td>
</tr>
</table>
JavaScriptは次のとおりです。
<script>
function addRow()
{
//add a row to the rows collection and get a reference to the newly added row
var newRow = document.all("myTable").insertRow();
var oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' onblur='addRow();'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='title'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='title'>";
}
</script>
しかし、ここでテーブルの上部に新しい行が追加されました。どうすればよいですか?