jQuery | nextUntil() with Examples
The nextUntil() is an inbuilt method in jQuery which is used to find all sibling elements between two given elements. Siblings are those having same parent element in DOM Tree. Document Object Model (DOM) is a World Wide Web Consortium standard. This defines for accessing elements in the DOM tree.
Here selector1 is the starting element after which siblings are going to be found out.
Parameters: It accepts a parameter “selector2” which is the last selected element to find the siblings.
Return Value: It returns all the siblings between “selector1” and “selector2”.
In the above code, all the elements (or siblings) between “span” and next “p” get highlighted.
In the below code, all the siblings between same pair of the elements can be selected.
In the above code, all the elements (or siblings) between the paragraph elements get highlighted with green color.