jQuery实例 - 添加与删除标签

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
           <div>
               <div style="display: inline-block">
                   <a onclick="Add(this);"><button>+</button></a>
               </div>
               <div style="display: inline-block">
                   <input type="checkbox">
                   <input type="text" value="IP">
               </div>
           </div>
       </div>

    <script src="../../jquery-1.12.4.js"></script>
    <script>
        function Add(self) {
            $(self).parentsUntil("outer").clone().find("a").html("<button>-</button>").attr("onclick","Remove(this);").end().eq(1).appendTo(".outer");
        }
        function Remove(self) {
            $(self).parentsUntil("outer").eq(1).remove();
        }
    </script>
</body>
</html>