juery实现多行添加,

<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>jQuery联系</title>
    <script src='./jquery-1.9.1.min.js'></script>
</head>
<center>
   <tr>
    <td>ID</td>
    <td>姓名</td>
    <td>职位</td>
    <td>薪水</td>
   </tr>
   <div >
  <table border=1>
   <tr>
    <td>1</td>
    <td>张三</td>
    <td>前端</td>
    <td>13k</td>
   </tr>
    </table>
    <input type='button' value='+增加一行' class='but'>
</div>
</body>
<script>
    $(function(){
        $('.but').click(function(){
            $('div:first').clone(true).insertAfter('div:last').append("<input type='button' value='-' class='del'>");
            $('.del').click(function(){
                $(this).parent().remove();
            })
        })
    })

</script>


juery批量添加表单

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="./jquery-1.9.1.min.js"></script>
</head>
<body>
<p id="bb"><input type="text"/></p>
<input type="button"value="点击" class="aa"/>
</body>
</html>
<script>
    $(function(){
        $('.aa').click(function(){
           var html='<p id="bb"><input type="text"/><span οnclick="fun(this)"><button>删除</button></span></p>';
            $('#bb').after(html);
        })
//        $('.ss').click(function(){
//            $(this).parent().remove();
//        })
   })
    function fun(ts){
        $(ts).parent().remove();
    }
</script>


<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<script src="./jquery-1.9.1.min.js"></script>
<body>
     <p id="c">文件<input type="text"/><button name="add">添加</button></p>
</body>
</html>
<script>
    $(document).on('click','button[name="add"]',function(){
        $("#c").after("<p>文件<input type='text'/><button name='add'>添加</button><button name='del'>删除</button></p>");
    });

    $(document).on('click','button[name="del"]',function(){
        var del = $(this).parent();
        del.remove();
    });


</script>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>jQuery联系</title>
    <script src='./jquery-1.9.1.min.js'></script>
</head>
<body>
<div id='d2'>
    <input type='file'>
    <input type='button' value='添加' class='but'>
</div>
</body>
<script>
    $(function(){
        $('.but').click(function(){
            $('div:first').clone(true).insertAfter('div:last').append("<input type='button' value='删除' class='del'>");
            $('.del').click(function(){
                $(this).parent().remove();
            })
        })
    })
</script>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值