// Find the function of the previous sibling element of the relevant element
Function Prev (ELEM ){
Do {
ELEM = ELEM. previussibling;
} While (ELEM & ELEM. nodetype! = 1 );
Return ELEM;
}
// Find the function of the first child element of an element
Function first (ELEM ){
ELEM = ELEM. firstchild;
Return ELEM & ELEM. nodetype! = 1?
Next (ELEM): ELEM;
}
// Find the function of the last child element of an element
Function last (ELEM ){
ELEM = ELEM. lastchild;
Return ELEM & ELEM. nodetype! = 1?
Prev (ELEM): ELEM;
}
// Find the function of the element parent Element
Function parent (ELEM; num ){
Num = num | 1;
For (VAR I = 0; I <num; I ++)
If (ELEM! = NULL) ELEM = ELEM. parentnode;
Return ELEM;
}
With these new functions, you can quickly traverse Dom documents without worrying about text between elements. For example, you need to find the next element of the
// Search for the next element of the
Next (first (document. Body ))