1. Return the first child element or null of the specified element.
Function first (OBJ) {var E = obj. firstchild; // obtain the first child node of the element while (E & E. nodetype! = 1) {// if the child node exists and the type is not equal to the element, search for the next node until the node type is E = E. nextsibling;} return E ;}
2. Return the last child element or null of the specified element.
Function last (OBJ) {var E = obj. lastchild; // obtain the last child node of the element while (E & E. nodetype! = 1) {// if the child node exists and the type is not equal to the element, search for the previous node until the node type is E = E. previussibling;} return E ;}
3. parentnode: Obtain the parent element of a specified node.
// Extend the parentnode pointer function to manipulate multiple parent elements at a time. // parameter: OBJ indicates the current node, and N indicates the level of the parent element to be manipulated. // return value: returns the function parent (OBJ, n) {var n = n | 1; // if the second parameter value is not specified, returns the parent element for (VAR I = 0; I <n; I ++) {// layer-by-layer traversal of the parent element if (E. nodetype = 9) break; // return the root element if (E! = NULL) E = E. parentnode; // obtain the parent element of the upper level }}
3. Obtain the last adjacent element or null of the specified element.
function pre(obj){ var e = obj.previousSibling; while(e && e.nodetype != 1){ e = e.previousSibling; } return e;}
4. Obtain the next adjacent element or null of the specified element.
function next(obj){ var e = obj.nextSibling; while(e && e.nodeType != 1){ e = e.nextSibling; } return e;}