Copy Code code as follows:
Compatible with Firefox gets a node of the same type of the last neighboring node
function Pervioussiblingsametype (node, cnode)
{
Return null directly for NULL
if (node.previoussibling = null)
{
return null;
}
Else
{
Node type unequal continue recursion
if (Node.previousSibling.nodeType!= cnode.nodetype)
{
Return Pervioussiblingsametype (node.previoussibling, Cnode);
}
If the node type is equal, it returns
else if (Cnode.nodetype = = Node.previousSibling.nodeType)
{
return node.previoussibling;
}
}
}
Compatible with Firefox gets the next adjacent node of the same type of node
function Nextsiblingsametype (node, cnode)
{
Return null directly for NULL
if (node.nextsibling = null)
{
return null;
}
Else
{
Node type unequal continue recursion
if (Node.nextSibling.nodeType!= cnode.nodetype)
{
Return Nextsiblingsametype (node.nextsibling, Cnode);
}
If the node type is equal, it returns
else if (Cnode.nodetype = = Node.nextSibling.nodeType)
{
return node.nextsibling;
}
}
}