js中insertAdjacentHTML的用法

来源:互联网 发布:数据库的货位编号编写 编辑:程序博客网 时间:2024/05/21 05:06

<div   id=mxh>原来的</div>  

  <input   onclick="document.all.mxh.insertAdjacentHTML('beforeBegin','<div>新 加的</div>')"   type=button   value="Insert   Before">  

  <input   onclick="document.all.mxh.insertAdjacentHTML('beforeEnd','<div>新加的 </div>')"   type=button   value="Insert   Before   End">

参数有两个,第一个:插入位置;第二个:插入内容;  

  第一个参数的意义:  


  [插在这里,值为"beforeBegin"]<div   id=test>[插在这里,值为"afterBegin"]    

    层内文字    

  [插在这里,值为"beforeEnd"]</div>[插在这里,值为"afterEnd"]   

原创粉丝点击