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>我需要为每一行附加编辑和删除按钮。单击编辑按钮时,行数据应加载到下拉列表和文本框。你能指导我这样做吗?
添加回答
举报
0/150
提交
取消