您的位置:首页 > 其它

网卡名字eth0,eth1的修改方法

2012-09-05 15:40 603 查看
JAVASCRIPT:

 

/* This is much faster than using (el.innerHTML = str) when there are many

existing descendants, because in some browsers, innerHTML spends much longer

removing existing elements than it does creating new ones. */

function replaceHtml(el, html) {

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

        var newEl = document.createElement(oldEl.nodeName);

        // Preserve the element's id and class (other properties are lost)

        newEl.id = oldEl.id;

        newEl.className = oldEl.className;

        // Replace the old with the new

        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;

};

 

another way:

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