// Compatible with Firefox to get the previous neighbor of the same type of a node Node
function previousSiblingSameType(node, cnode)
{
// If it is empty, return null directly
if(node.previousSibling == null)
{
return null;
}
else
{
// Continue recursion if node types are not equal
if(node.previousSibling.nodeType != cnode.nodeType)
{
return perviousSiblingSameType(node.previousSibling , cnode);
}
// If the node types are equal, return
else if(cnode.nodeType == node.previousSibling.nodeType)
{
return node.previousSibling;
}
}
}
// Compatible with Firefox to get the next adjacent node of the same type of a node
function nextSiblingSameType(node, cnode)
{
// is Empty returns null directly
if(node.nextSibling == null )
{
return null ;
}
else
{
// Continue recursion if node types are not equal
if(node.nextSibling.nodeType != cnode.nodeType)
{
return nextSiblingSameType(node.nextSibling , cnode);
}
// If the node types are equal, return
else if(cnode.nodeType == node.nextSibling.nodeType)
{
return node.nextSibling ;
}
}
}