jquery的clon
2021-03-05 18:26
标签:col doctype ext query NPU body attr type his jquery的clon 标签:col doctype ext query NPU body attr type his 原文地址:https://www.cnblogs.com/TKOPython/p/12904780.htmlDOCTYPE html>
html lang="en">
head>
meta charset="UTF-8">
title>Titletitle>
script src="jquery-3.1.1.js">script>
head>
body>
div id="tianjiaclon">
div id="ddddd">
input type="button" value="+" onclick="f(this)">
input type="text">
div>
div>
body>
script>
function f(self) {
var s = $(self).parent().clone(); //获取到this的点击事件后,返回父标签,进行clon
//把clon出来的标签的"+"号变为"-"号
s.children(":button").val("-").attr("onclick","f1(this)");
$("#tianjiaclon").append(s); //把clon的信息添加到,最外层的div标签中
}
function f1(self) {
//点击"-"号把clon当前对象删除
$(self).parent().remove();
}
script>
html>