The example in this article describes the jQuery method of searching for peer elements. Share it with everyone for your reference. The specific analysis is as follows:
1. next() method
is used to search for a single sibling element immediately following each matching element. You can also specify a selector to filter sibling elements as needed. The syntax format is as follows:
2. nextAll() method
is used to search for all sibling elements immediately following each matching element. If necessary, you can also specify a selector to filter sibling elements
3. nextUtil() method
is used to get the sibling elements immediately following each matching element, up to (but not including) the element matching the given selector, in the following format:
Example:
Set the borders of all intermediate sibling elements from the element with id div1 to the end of the next div element to red
4. prev() method
is used to search for a single sibling element immediately before each matching element. You can also specify a selector to filter sibling elements as needed. The syntax format is as follows:
Example:
5. prevAll() method
is used to search for all sibling elements before the current element. You can also specify a selector to filter sibling elements. The syntax format is as follows:
6. prevUtil() method
is used to search all sibling elements before the current element until the matching element is encountered. The syntax format is as follows:
7. siblings() method
is used to search all sibling elements of each matching element. If necessary, you can also specify a selector to filter these sibling elements. The format is as follows:
An example is as follows:
Single room (already occupied) | Double Room (not staying) | Deluxe Suite (Already stayed) | Single room (already occupied) | Deluxe Suite (not staying) |
Single Room (Already occupied) | Double Room (not staying) | Deluxe Suite (not staying) | Single Room (not staying) | Deluxe Suite (not staying) |
Single Room (not staying) | Double Room (not staying) | Deluxe Suite (Already stayed) | Single Room (Already occupied) | Deluxe Suite (not staying) |
Single Room (Already occupied) | Double Room (Already occupied) | Deluxe Suite (not staying) | Single Room (not staying) | Deluxe Suite (Already stayed) |
Single Room (Already occupied) | Double Room (not staying) | Deluxe Suite (Already stayed) | Single Room (Already occupied) | Deluxe Suite (not staying) |
The rendering is as follows:
I hope this article will be helpful to everyone’s jQuery programming.