`

IE和FF中获取兄弟节点

阅读更多
function getNextNode(target){
	var rel=target;
	do{
	  rel=rel.nextSibling;
	}while(rel.nodeType!=1)
	return rel
}

至于这么些的原因
见下面
nodeType = 3是文本节点
nodeType = 1是html节点
引用

firefox 解释:
previousSibling:The node immediately preceding the given one in the tree, or null if there is no sibling node.
nextSibling :The node immediately following the given one in the tree, or null if there is no sibling node

ie解释:
previousSibling:Retrieves a reference to the previous child of the parent for the object. 获取对此对象的上一个兄弟对象的引用。
nextSibling :Retrieves a reference to the next child of the parent for the object.获取对此对象的下一个兄弟对象的引用。


可以 这么理解
firefox 中的tree是只node级别,而ie中是element级别
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics