我是靠谱客的博主 合适硬币,这篇文章主要介绍FF火狐下获取一个元素同类型的相邻元素实现代码,现在分享给大家,希望可以做个参考。

复制代码 代码如下:

// 兼容火狐获取一个节点的相同类型的上一个相邻节点
function perviousSiblingSameType(node , cnode )
{
// 为空直接返回null
if(node.previousSibling == null )
{
return null ;
}
else
{
// 节点类型不相等继续递归
if(node.previousSibling.nodeType != cnode.nodeType)
{
return perviousSiblingSameType(node.previousSibling , cnode);
}
// 节点类型相等则返回
else if(cnode.nodeType == node.previousSibling.nodeType)
{
return node.previousSibling ;
}
}
}

// 兼容火狐获取一个节点的相同类型的下一个相邻节点
function nextSiblingSameType(node , cnode)
{
// 为空直接返回null
if(node.nextSibling == null )
{
return null ;
}
else
{
// 节点类型不相等继续递归
if(node.nextSibling.nodeType != cnode.nodeType)
{
return nextSiblingSameType(node.nextSibling , cnode);
}
// 节点类型相等则返回
else if(cnode.nodeType == node.nextSibling.nodeType)
{
return node.nextSibling ;
}
}
}

最后

以上就是合适硬币最近收集整理的关于FF火狐下获取一个元素同类型的相邻元素实现代码的全部内容,更多相关FF火狐下获取一个元素同类型内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(129)

评论列表共有 0 条评论

立即
投稿
返回
顶部