您的位置:首页 > Web前端 > JavaScript

js中insertAdjacentHTML的用法

2013-10-29 16:45 85 查看
<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"]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: