我想創建一個表來進行enter code here插入,update并且delete.這個想法是用表格替換表格,例如創建一個表格,只有標題和準備插入數據的空行,填充第一行或動態創建第二行或放置按鈕添加行并返回寫入內容和插入等等。我正在嘗試這種方式,但因此我無法在列中寫入然后進行插入:<table id="products-table"> <tbody> <tr> <th>Produto</th> <th>Código</th> <th>Quantidade</th> <th>Pre?o</th> <th>A??es</th> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> <button onclick="RemoveTableRow(this)" type="button">Remover</button> </td> </tr> </tbody> <tfoot> <tr> <td colspan="5" style="text-align: left;"> <button onclick="AddTableRow()" type="button">Adicionar Produto</button> </td> </tr> </tfoot> </table> <script>(function($) { AddTableRow = function() { var newRow = $("<tr>"); var cols = ""; cols += '<td> </td>'; cols += '<td> </td>'; cols += '<td> </td>'; cols += '<td> </td>'; cols += '<td>'; cols += '<button onclick="RemoveTableRow(this)" type="button">Remover</button>'; cols += '</td>'; newRow.append(cols); $("#products-table").append(newRow); return false; };})(jQuery); </script> 但我質疑,創建一個表格來替換 html 中的表單是否有意義?
- 2 回答
- 0 關注
- 294 瀏覽
添加回答
舉報
0/150
提交
取消