1:在哪里插入html
2:要插入的html字符串

解决方案 »

  1.   

    例子:
    <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">
      

  2.   

    参数有两个,第一个,插入位置;第二个,插入内容;第一个参数的意义:[插在这里,值为"beforeBegin"]<div id=test>[插在这里,值为"afterBegin"] 层内文字 [插在这里,值为"beforeEnd"]</div>[插在这里,值为"afterEnd"] 
      

  3.   

    <div> 层内文字层内文字层内文字层内文字层内文字 </div>
    ^    ^------  "afterBegin"                    ^      ^-- "afterEnd"
    ^-----------  "beforeBegin"                   ^--------- "beforeEnd"