目录

clone()

功能

创建指定的dom节点的副本。

语法

noder.clone(node,deep)

参数

范例

Example: 点击按钮,data-deep=true,复制成功,否则不成功。

<!DOCTYPE html>
<html>

<head>
    <style>

    </style>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script>
    <script>
    require.config({
        baseUrl: "./",
        packages: [{
            name: "skylark",
            location: "../../../src/skylark"
        }, ]
    });
    </script>
</head>

<body>
    <div>
        <button data-deep=false>clone</button>
        <button data-deep=true>cloneDeep</button>
        <p>Hello, how are you?</p>
    </div>
    <script>
    require(["skylark/query", "skylark/noder"], function($, noder) {
        $("button").on("click", function() {
            var value = $(this).data().deep;
            var node = noder.clone($("p:first")[0], value);
            $("div").addContent($(node).append(" clone with deep: " + value));
        });
    });
    </script>
</body>

</html>