Take the brother node of a DOM element and use the native JS Code to do it in the form of jQuery's siblings method.
The Code is as follows:
Function siblings (o) {// The parameter o is the sibling node of the user who wants to retrieve the element.
Var a = []; // defines an array to store the brother elements of o.
Var p = o. previussibling;
While (p) {// The brothers who take o first determine whether there is any previous brother element. If so, execute p to indicate previussibling.
If (p. nodeType = 1 ){
A. push (p );
}
P = p. previussibling // Finally, assign the previous node to p
}
A. reverse () // reverse the order so that the order of elements is sequential.
Var n = o. nextSibling; // obtain the younger brother of o.
While (n) {// determine if there is any younger brother node. n indicates nextSibling.
If (n. nodeType = 1 ){
A. push (n );
}
N = n. nextSibling;
}
Return a // Finally, return this group of elements in the order from the boss to the old and small
}