Your generous donation allows me to continue developing and updating my code!
With jQuery Untils you easily traverse forward along next siblings, backwards along previous siblings, and upwards along parents, selecting all elements (or just elements that match an optional selector).
A simple nextUntil example, with an "until" selector
- List item with a class of "a"
- List item with a class of "b"
- List item with a class of "c"
- List item with a class of "d"
- List item with a class of "e"
- List item with a class of "f"
The code
$(function(){ // Example 1: From .a, select all next sibling elements until .f $('#ex1 .a').nextUntil('.f').addClass('selected'); });
A more complex nextUntil example, with both an "until" and "each" selector
Paragraph with a class of "a"
Span with a class of "b"Paragraph with a class of "c"
Span with a class of "d"Paragraph with a class of "e"
Span with a class of "f"The code
$(function(){ // Example 2: From .a, select all next sibling 'p' elements until .f $('#ex2 .a').nextUntil('.f', 'p').addClass('selected'); });