<html>
<head>
<title>insertAdjacentHTML插入新内容</title>
<script language="jscript">
function addsome()
{
document.all.paral.insertAdjacentHTML("afterBegin","<h1>在文本前容器内插入内容</h1>");
document.all.paral.insertAdjacentHTML("beforeEnd","<h2>在文本后容器内插入内容</h2>");
document.all.paral.insertAdjacentHTML("beforeBegin","<h4>在文本前容器外插入内容</h1>");
document.all.paral.insertAdjacentHTML("afterEnd","<h5>在文本后容器外插入内容</h2>");
}
</script>
</head>
<body onload="addsome()">
<div id="paral" style="fontsize:6;color='#ff00ff'">原来的内容</div><hr>
</body>
</html>
from: http://www.cnblogs.com/shj0633/archive/2007/01/13/619581.html
本文介绍了一种利用insertAdjacentHTML方法在DOM元素的不同位置插入HTML内容的方法。通过具体实例展示了如何在元素前后及内部添加新的HTML片段。
301

被折叠的 条评论
为什么被折叠?



