Jquery 写表单增加,删除行列

				<div class="form-item-line">
                    <div class="line-tit">主要排放物或污染源</div>
                    <div class="line-table">
                        <table class="layui-table expand-table" id="yypfwhwry">
                            <colgroup>
                                <col width="60">
                                <col>
                                <col>
                                <col width="130">
                                <col width="135">
                                <col width="60">
                                <col width="60">
                            </colgroup>
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>污染物形态</th>
                                <th>污染物名称</th>
                                <th>污染物排放浓度</th>
                                <th>污染物排放量/日</th>
                                <th>单位</th>
                                <th><i class="gyyq-iconfont table-add">&#xe66f;</i></th>
                            </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
	
	<div id="hide-container" style="display: none;">
	<table class="yypfwhwry">
        <tr class="data-row">
            <td class="order"></td>
            <td><input type="text" class="layui-input" /></td>
            <td><input type="text" class="layui-input" /></td>
            <td><input type="text" class="layui-input" /></td>
            <td><input type="text" class="layui-input" /></td>
            <td><input type="text" class="layui-input" /></td>
            <td><i class="gyyq-iconfont table-delete">&#xeb5d;</i></td>
        </tr>
	</table>
</div>
</body>
<script type="application/javascript">
    $(function(){
    $('table.expand-table .table-add').on('click', function () {
        var $table = $(this).closest('table');
        var id = $table.attr('id');
        var $tr = $('#hide-container').find('.' + id).find('tr').clone(true);
        $table.append($tr);
        resetRowNum($table);
    });
    $('table.expand-table').delegate('.table-delete', 'click', function () {
        var $table = $(this).closest('table');
        $(this).closest('tr').remove();
        resetRowNum($table);
    });
    var resetRowNum = function (target) {
        $(target).find('.data-row').each(function (i) {
            $(this).find('.order').text(i + 1);
        });
    }
    })
</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值