• 克隆元素


    clone() 创建匹配结果及其后代和文本节点的副本

    示例:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title>克隆</title>
            </script>
        </head>
        <body>
            <div style=" font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; padding: 0px !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; auto !important; min-height: auto !important;">>
                <ul id="ul">
                    <li id="a">鼠标</li>
                    <li id="b">键盘</li>
                    <li id="c">屏幕</li>
                    <li id="d"><a>主机</a></li>
                </ul>
            </div>
     
            <button>克隆</button>
            <script>
                $('button').on('click', function () {
                    // 克隆鱼粉
                    $li = $('#d').clone();
                    // 移除鱼粉
                    $('#d').remove();
                    // 将克隆的鱼粉插入到油条前
                    $li.insertBefore('#a');
                });
            </script>
        </body>
    </html>
  • 相关阅读:
    js 删除字符串中所有空格
    jquery easyui datagrid 设置设置在选中的所有行中只选择第一行
    编译Linux内核时出现错误gcc: error: elf_i386: No such file or directory
    AD9打印丝印层
    s3c2410 board.c分析
    2010.03 u-boot--Makefile完全分析
    mini6410移植--uboot移植(2)
    mini6410移植--uboot移植(1)
    uboot之uboot.lds文件分析
    Linux启动过程
  • 原文地址:https://www.cnblogs.com/max-hou/p/9151899.html
Copyright © 2020-2023  润新知