简单的增行减行

 简单,直接放代码

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            button{
                margin-left: 20px;
            }
            ul li{
                margin-bottom: 10px;
            }
        </style>
    </head>
    <body>
        <div class="box">
            <button onclick="add()">添加</button>
            <ul id="ul_li">
                
            </ul>
        </div>
    </body>
    <script src="js/jquery.min.js"></script>
    <script>
        function add(){
            $("#ul_li").append('<li><input type="text" /><button onclick="del(this)">删除</button></li>')
        }
        function del(opp){
            $(opp).parent().remove(); 
        }
    </script>
</html>

 

posted @ 2018-07-13 18:01  wanan_01  阅读(125)  评论(0编辑  收藏  举报