Jquery表格行列操作
2016-11-25 12:38
260 查看
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head> <body> <table border="1"> <tr> <td>JQuery</td> <td>Jquery</td> </tr> <tr> <td>JQuery</td> <td>Jquery</td> </tr> </table> <input type="button" name="button" id="button" value="加列" onclick="AddCol();"/> <input type="button" name="button" id="button" value="加行" onclick="AddRow();"/> <input type="button" name="button" id="button" value="减列" onclick="RemoveCol();"/> <input type="button" name="button" id="button" value="减行" onclick="RemoveRow();"/> <script type="text/JavaScript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script> // 删除行 function RemoveRow() { // remove可以直接删除行或列 $("tr:last").remove(); } //删除列 function RemoveCol() { $("tr td:last-child").remove(); } // 增加行 function AddRow() { //调用clone函数复制要添加的行,再使用appendTo向表的尾部加入新的行 $("tr:first").clone().appendTo("table:first"); } //增加列 function AddCol() { //append()函数增加列 $("tr").append("<td>JQuery</td>"); } </script> </body> </html>
相关文章推荐
- 用jquery代码实现表格行列的增删操作(每行编号随之修改)
- jquery操作表格
- JQuery 表格操作(交替显示、拖动表格行、选择行等)
- jQuery 可编辑表格文本域,支持键盘快捷操作
- 提高表格操作的十五款jQuery插件
- 提高表格操作的十五款jQuery插件
- JQuery操作一个表格
- jquery 操作表格实现代码(多种操作打包)
- 《锋利的jQuery》要点归纳(四)jQuery对表单、表格的操作及更多应用(中:表格应用)
- 《锋利的jQuery》要点归纳(四)jQuery对表单、表格的操作及更多应用(上:表单应用)
- 一个基于jQuery的锁定表格行列的js脚本
- JQuery 表格操作(交替显示、拖动表格行、选择行等)
- JQuery操作表格
- 15款提高表格操作的jQuery插件
- jQuery 可编辑表格文本域,支持键盘快捷操作
- 使用 JQuery 操作表格(交替显示、拖动表格行、选择行等)
- jQuery 对表格进行操作
- 15款提高表格操作的jQuery插件
- JQuery表格操作练习
- 分享一个基于jQuery的锁定表格行列的js脚本