function replaceHtml(el, html) {
var oldEl = typeof el === "string" ? document.getElementById(el) : el;
/*@cc_on // The original innerHTML performs better in IE
oldEl.innerHTML = html;
return oldEl ;
@*/
var newEl = oldEl.cloneNode(false);
newEl.innerHTML = html;
oldEl.parentNode.replaceChild(newEl, oldEl);
/* Once we Remove the old element from the DOM and return the new element reference. */
return newEl;
};
There is still performance improvement for Opera, but the improvement is not as amazing as the above two browsers.
Only in IE, The original innerHTML method is more efficient.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn