一、总结
1、方法——>clone()
2、克隆事件否?——>true\false
二、案例
一、代码如下:
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-3.3.1.js" ></script>
</head>
<body>
<input type="button" value="按钮"/>
<script>
$("[type='button']").bind("click",function(){
console.log("按钮");
})
$("[type='button']").after($("[type='button']").clone(true));
</script>
</body>
</html>
此时的复制的按钮可以使用事件绑定
二、代码如下:
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-3.3.1.js" ></script>
</head>
<body>
<input type="button" value="按钮"/>
<script>
$("[type='button']").bind("click",function(){
console.log("按钮");
})
$("[type='button']").after($("[type='button']").clone(false));//clone方法传入false或不传入值,则后插入的按钮没有点击事件
</script>
</body>
</html>
此时的按下按钮不可以执行事件