私は行を含む表を作成し、最後に各行に 'td'があります。新しい行を挿入するための 'img'があります。onClick = "addRow()"この新しい行をクリックした行の下に挿入します。私は、行X及び列Yを持っていると私はXの行の「IMG」をクリックした場合明らかに、私はXの下に新しい行を取得し、Y. の上に私が挿入するためにこのコードを使用:jQueryで新しい行(特別な場合)を追加しますか?
function addRow()
{
var newRow = document.all("tblGrid").insertRow(-1);
var oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t1'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t2'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t3'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t4'>";
}
とこのテーブル:
<table id="tblGrid" cellspacing="0">
<tr>
<th>Instraction</th>
<th>Result</th>
<th>Time</th>
<th>Date</th>
<th>Add</th>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_instRecordset['instName']; ?></td>
<td><?php echo $row_instRecordset['instValue']; ?></td>
<td><?php echo $row_instRecordset['instTime']; ?></td>
<td><?php echo $row_instRecordset['instDate']; ?></td>
<td><img onClick="addRow()" width="20px" height="20px" src="images/add_32.png"/></td>
</tr>
<?php } while ($row_instRecordset = mysql_fetch_assoc($instRecordset)); ?>
</table>
私はこれをjQueryでどうやって行うことができますか?私はまた、現在の日付となる第3のセルと、現在の日付の自動生成される第4のセルが必要ですか? 任意の助けが理解されるであろう... jQueryので
ありがとうございます。これは、テーブルの最後に行を挿入します。 – 7kemZmani