国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

jQuery實現html表格動態添加新行的方法

2024-05-06 16:20:59
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了jQuery實現html表格動態添加新行的方法,涉及jQuery鼠標事件及頁面元素的操作技巧,需要的朋友可以參考下

本文實例講述了jQuery實現html表格動態添加新行的方法。分享給大家供大家參考。具體實現方法如下:

 

 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  3. <html xmlns="http://www.w3.org/1999/xhtml"
  4. <head> 
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  6. <title>Add Row example</title> 
  7. <script src="jquery-1.6.2.min.js"></script> 
  8. <script type="text/javascript"
  9. <!-- jQuery Code will go underneath this --> 
  10. $(document).ready(function () {  
  11. // Code between here will only run when the document is ready 
  12. $("a[name=addRow]").click(function() { 
  13. // Code between here will only run  
  14. //when the a link is clicked and has a name of addRow 
  15. $("table#myTable tr:last").after('<tr><td>Row 4</td></tr>'); 
  16. return false
  17. }); 
  18. }); 
  19. </script> 
  20. </head> 
  21. <body> 
  22. <table style="width: 100%" id="myTable"
  23. <tr><td>Row 1</td></tr> 
  24. <tr><td>Row 2</td></tr> 
  25. <tr><td>Row 3</td></tr> 
  26. </table> 
  27. <a href="#" name="addRow">Add Row</a> 
  28. </body> 
  29. </html> 

希望本文所述對大家的jQuery程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 海门市| 正镶白旗| 万载县| 城固县| 陈巴尔虎旗| 宁国市| 夏津县| 淳化县| 多伦县| 灵台县| 凤台县| 陇川县| 沁水县| 旬邑县| 乌鲁木齐县| 卢湾区| 米脂县| 英吉沙县| 扎赉特旗| 怀化市| 丹凤县| 罗山县| 滁州市| 双峰县| 平武县| 永康市| 逊克县| 湘乡市| 成武县| 新干县| 恩施市| 任丘市| 信阳市| 深州市| 萨迦县| 德兴市| 多伦县| 桐柏县| 明水县| 鄱阳县| 青河县|