var tb = $('#example').DataTable();$('#addRow').on('click', function() { var typeName = $("#type option:selected").val(); var amount = $("#amount").val(); tb.row.add([typeName, amount]).draw();});<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script><script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script><label>Type</label><select id="type"> <option> Type 01</option> <option> Type 02</option></select><label>Amount</label><input type="text" id="amount" /><button id="addRow"> Add </button><table id="example" class="display" cellspacing="0" width="100%"> <thead> <tr> <th>Type</th> <th>Amount</th> </tr> </thead></table>我需要為每一行附加編輯和刪除按鈕。單擊編輯按鈕時,行數(shù)據(jù)應(yīng)加載到下拉列表和文本框。你能指導(dǎo)我這樣做嗎?
jquery datatable 使用表單編輯表行數(shù)據(jù)
慕工程0101907
2021-06-28 08:59:16