nextSibling IE有效 FF无效
浏览量:815
parentNode 、childNodes 、 previousSibling和nextSibling,FF和IE9中会把回车行换当作一个#TEXT节点。要把html中的空格和换行都去掉就好了,汗。
function nextSib(node){
var tempLast = node.parentNode.lastChild;
if(node == tempLast)
return null;
var tempObj=node.nextSibling;
while(tempObj.nodeType != 1 && tempObj.nextSibling != null)
temObj = tempObj.nextSibling;
return (tempObj.nodeType == 1)? tempObj:null;
}
function prvSib(node){
var tempFirst = node.parentNode.firstChild;
if(node == tempFirst)
return null;
var temObj= node.previousSibling;
while(temObj.nodeType !=1 && temObj.previousSibling != null)
temObj = temObj.previousSibling;
return (temObj.nodeType == 1)? temObj:null;
}


感谢支持与鼓励~