클론 노드 cloneNode()

6703 단어
DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>    cloneNode()title>
    
     <style>
        #div{
            width: 300px;
            height: 30px;
            background: red;
            margin: 20px;     
        }
     style>
head>
<body>
    <div id="div">   divdiv>
    <script>
        var div=document.getElementById("div");//  div
        var newdiv=div.cloneNode(true);//  div    
        newdiv.innerHTML+=",no,      div";//   div    
        document.body.insertBefore(newdiv,div);//   div   div  
    script>
body>
html>

좋은 웹페이지 즐겨찾기