日期:2014-05-16 浏览次数:20507 次
<script type ="text/javascript">
$(function()
{
var title = "标题"
var id = "001";
var newNode;
newNode = ParseDom("<fieldset><legend>" + title +"</legend><div id='"+ id +"'></div></fieldset>");
document.getElementById("divContainer").appendChild(newNode); //不想放这里
var innerDiv = newNode.document.getElementById(id);
innerDiv.innerHTML = "测试内容";
//document.getElementById("divContainer").appendChild(newNode); //为了性能,我想把这句放这里
}
)
function ParseDom(content)
{
var newObject = document.createElement("div");
newObject.innerHTML = content;
return newObject;
};
</script>
var title = "标题"
var id = "001";
var newNode;
newNode = ParseDom("<fieldset><legend>" + title +"</legend><div id='"+ id +"'></div></fieldset>");
//document.getElementById("divContainer").appendChild(newNode); //不想放这里
//var innerDiv = newNode.document.getElementById(id);
var innerDiv = newNode.getElementsByTagName('div')[0] /////用getElementsByTagName 代替
innerDiv.innerHTML = "测试内容";
&n