jQuery克隆小例子

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>克隆</title>
    <style>
        .b1 {
            height: 50px;
            width: 100px;
            background-color: gold;
            color: red;
        }
    </style>
</head>
<body>

<button class="b1">屠龙宝刀,点击就送</button>
<script src="jquery-3.3.1.min.js"></script>
<script>
    $(".b1").click(function () {
        console.log(this);
//        $(this).after($(this).clone());
        $(this).clone(true).insertAfter(this);
    })
</script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/miaoqinian/article/details/80582586