javascript拓展DOM操作 prependChild insertAfert
时间:2021-04-20 08:54:05|栏目:|点击: 次
以下是自己写的一个拓展函数,虽然网上已经有了,仅当做自己练兵。。。
function prependChild(o,s){
if(s.hasChildNodes()){
s.insertBefore(o,s.firstChild);
}else{
s.appendChild(o);
}
}
function insertAfert(o,s){
if(s.nextSibling!=null){
s.parentNode.insertBefore(o,s.nextSibling);
}else{
s.parentNode.appendChild(o);
}
}
复制代码 代码如下:
function prependChild(o,s){
if(s.hasChildNodes()){
s.insertBefore(o,s.firstChild);
}else{
s.appendChild(o);
}
}
function insertAfert(o,s){
if(s.nextSibling!=null){
s.parentNode.insertBefore(o,s.nextSibling);
}else{
s.parentNode.appendChild(o);
}
}
上一篇:惊人文件拷贝速度- FastCopy 1.52 汉化美化版下载
栏 目:
下一篇:易语言打开文件件网页的方法
本文标题:javascript拓展DOM操作 prependChild insertAfert
本文地址:http://www.codeinn.net/misctech/104732.html






