网卡名字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:
/* 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; };
相关文章推荐
- 网卡名字eth0,eth1的修改方法
- 转: 网卡名字eth0,eth1的修改方法
- centos克隆 网卡eth1变成eth0修改方法
- centos网卡eth1变成eth0修改方法
- centos网卡eth1变成eth0修改方法
- vmware workstation中克隆后centos网卡eth1变成eth0修改方法
- centos网卡eth1变成eth0修改方法
- centos网卡eth1变成eth0修改方法
- linux下网卡eth1如何修改为eth0
- Debian 9系统下修改默认网卡为eth0的方法
- VM 克隆的 centos 的Linux下网卡eth1如何修改为eth0解决办法
- Linux下网卡eth1如何修改为eth0
- 修改Linux网卡由eth1变成eth0
- Linux下网卡eth1如何修改为eth0
- 网卡name-eth1如何修改为eth0
- (linux)复制的虚拟机网卡eth0变成了eth1或其他名称后修正方法
- redhat7.0修改网卡名字为eth0
- Linux下网卡eth1如何修改为eth0
- Linux网卡eth0变成eth1修改方法
- vmware workstation克隆linux后修改网卡为eth0方法