zoukankan      html  css  js  c++  java
  • document对象-操作元素的文档结构

     1 <!DOCTYPE html>
     2 <html>
     3 <head lang="en">
     4     <meta charset="UTF-8">
     5     <title></title>
     6     <script type="application/javascript">
     7         function addFile(){
     8             //创建父亲元素对象
     9             var div=document.getElementById("container")
    10             
    11             var input1 =document.createElement("input")
    12             var br=document.createElement("br")
    13             input1.type="file"
    14             var input2 =document.createElement("input")
    15             input2.type="button"
    16             input2.value="删除"
    17             input2.onclick=function(){
    18                 div.removeChild(input1)
    19                 div.removeChild(br)
    20                 div.removeChild(input2)
    21             }
    22             div.appendChild(input1)
    23             div.appendChild(input2)
    24             div.appendChild(br)
    25 
    26         }
    27     </script>
    28 </head>
    29 <body>
    30     <input type="button" value="添加附件" onclick="addFile()">
    31     <hr>
    32     <div id="container"></div>
    33 </body>
    34 </html>
  • 相关阅读:
    day20(顺时针打印矩阵)
    day18(树的子结构)
    JAVA WEB应用
    hexo 写作
    解决
    Github构建个人主页之写作
    Github构建个人主页之建站
    hive HQL数据库操作笔记02
    python scrapy爬虫笔记01
    spark笔记01
  • 原文地址:https://www.cnblogs.com/vieta/p/10833568.html
Copyright © 2011-2022 走看看