From:http://blog.stevenlevithan.com/archives/faster-than-innerhtml

http://lveyo.javaeye.com/blog/182891

http://fins.javaeye.com/blog/183373

function replaceHtml(el, html) {

	var oldEl = typeof el === "string" ? document.getElementById(el) : el;

	/*@cc_on // Pure innerHTML is slightly faster in IE

		oldEl.innerHTML = html;

		return oldEl;

	@*/

	var newEl = oldEl.cloneNode(false);

	newEl.innerHTML = html;

	oldEl.parentNode.replaceChild(newEl, oldEl);

	/* Since we just removed the old element from the DOM, return a reference

	to the new element, which can be used to restore variable references. */

	return newEl;

};

评论
发表评论

您还没有登录,请登录后发表评论

liudaoru
搜索本博客
最近加入圈子
存档
最新评论