博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JQuery动态给table添加、删除行
阅读量:6884 次
发布时间:2019-06-27

本文共 1154 字,大约阅读时间需要 3 分钟。

hot3.png

<html> 

<head> 
<SCRIPT language=JavaScript src="jquery.js" mce_src="jquery.js"></SCRIPT> 
<SCRIPT language=JavaScript> 
$("document").ready(function(){ 
    //第六个表格的删除按钮事件绑定  
    $("#tbody6 .del").click(function() {  
        $(this).parents(".repeat").remove();  
    });  
    //第六个表格的添加按钮事件绑定  
    $("#add6").click(function(){  
       // $("#tbody6>.template")  
            //连同事件一起复制  
           // .clone(true)  
            //去除模板标记  
           // .removeClass("template")  
            //修改内部元素  
           /// .find(".content")  
           //     .text("新增行")  
          //      .end() 
          // .find(".del")  
          //      .text("删除")  
          //      .end()       
            //插入表格  
          //  .appendTo($("#tbody6"))  
          $("#table6").append("<tr><td>33</td><td>44</td></tr>");
    });  
</script> 
</head> 
<body> 
    <table border=1 id="table6">  
    <tbody id="tbody6">  
        <tr class="template repeat">  
            <td class="content">这里是模板 by yanleigs Email:landgis@126.com</td>  
            <td><button class="del">模板,不要删除</button></td>  
        </tr>  
        <tr class="repeat">  
            <td class="content">这行原来就有</td>  
            <td><button class="del">删除</button></td>  
        </tr>  
        <tr class="repeat">  
            <td class="content">这行原来就有</td>  
            <td><button class="del">删除</button></td>  
        </tr>  
    </tbody>  
    <tfoot>  
        <tr>  
            <td> </td>  
            <td><button id="add6">添加</button></td>  
        </tr>  
    </tfoot>  
</table>  
</body> 
</html> 

转载于:https://my.oschina.net/wuyizhong/blog/78967

你可能感兴趣的文章
webpack01
查看>>
NoSQL 简介
查看>>
功能测试思考点
查看>>
PHP代码审计
查看>>
杭电4786--Fibonacci Tree(生成树)
查看>>
git 基础
查看>>
搜索高亮
查看>>
图片上没有line-height垂直居中
查看>>
图片标记 : 行内元素 单边标记
查看>>
canvas基础—图形变换
查看>>
NOIP2014 T4 子矩阵 dfs+dp
查看>>
OO方式实现ALV: cl_salv_table
查看>>
php 使用 restler 框架构建 restfull api
查看>>
makefile中的变量赋值
查看>>
基于KVM的虚拟化研究及应用
查看>>
Libvirt 虚拟化库剖析
查看>>
计算机英语
查看>>
MSDN--Windows Server
查看>>
我永远喜欢我的偶像 KIKU
查看>>
笔记本桌面网卡图标长期保持*图案
查看>>