博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

insertAdjacentHTML("beforeEnd", html的含义和用法

Posted on 2017-02-15 11:38  程序员入门到放弃  阅读(2875)  评论(0编辑  收藏  举报

document.getElementById("nim")为:获得名称为nim的层。
insertAdjacentHTML("beforeEnd", html)为:
nim层在其后追加插入内容为< INPUT type="file" size="50" NAME="File"> 的html格式信息。

向下面的例子,可以拷贝到网页中试试:
<script>
   function addFile()
   {
       var str = '<INPUT type="file" size="50" NAME="File">'
      var nim = document.getElementById("nim")

  nim.insertAdjacentHTML("beforeEnd", html)

   }
  </script> 
<div id="nim">
1234567
</div>dfdfdfdf
<a href="javascript:addFile()">df</a>