bom.html 878 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  4. <head>
  5. </head>
  6. <body>
  7. <br>
  8. <table id="mt" border="1" cellpadding="5" cellspacing="0">
  9. <thead>
  10. <th>產品編號</th>
  11. <th>產品名稱</th>
  12. </thead>
  13. <tbody></tbody>
  14. <p><input type = "button" id="add" value = "新增" /></p>
  15. <p><input type = "button" id="del" value = "刪除" /></p>
  16. </table>
  17. <script type="text/javascript">
  18. var tag = 1;
  19. $(function(){
  20. $("#add").click(function(){
  21. $('#mt tbody').append('<tr><td>A0000'+tag+'</td><td><input type = "text"/></td></tr>');
  22. tag++;
  23. });
  24. $("#del").click(function(){
  25. $("#mt tbody tr:last").remove();
  26. });
  27. })
  28. </script>
  29. </body>
  30. </html>