亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

創建空表并插入數據

創建空表并插入數據

PHP
30秒到達戰場 2021-09-05 20:43:58
我想創建一個表來進行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>&nbsp;</td>                <td>&nbsp;</td>                <td>&nbsp;</td>                <td>&nbsp;</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>&nbsp;</td>';      cols += '<td>&nbsp;</td>';      cols += '<td>&nbsp;</td>';      cols += '<td>&nbsp;</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 回答

?
哈士奇WWW

TA貢獻1799條經驗 獲得超6個贊

它確實有道理,我建議您查看DataTable,它使您能夠使用適當的回調和所有方法處理此類用例。唯一的限制是您需要 jQuery。


查看完整回答
反對 回復 2021-09-05
  • 2 回答
  • 0 關注
  • 294 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號