Phương pháp thứ ba có sẵn để lựa chọn các yếu tố tiếp theo anh chị em là nextUntil () phương pháp Như tên gọi của nó cho thấy, phương pháp này sẽ trả về tất cả các yếu tố tiếp theo cho đến khi chọn một là lần xuất hiện. Điều quan trọng | CHAPTER 2 COMMON JQUERY ACTIONS AND METHODS .next This generates the following output .next P A selector can be passed to .next as well which allows developers to determine which type of next sibling element should be matched .next bar This returns an empty result set since the next element does not have an ID of bar .next bar Because .next returns only one element a companion method was created that returns all next sibling elements .nextAll . To select all paragraphs after the paragraph with the class foo use the following code .foo .nextAll p This returns the following result .foo .nextAll p p p bar Note The selector is optional in .nextAll as it is in .next . The third method available for selecting next sibling elements is the .nextUntil method. As its name suggests this method will return all next elements until a selector is matched. It s important to note that the element matched by the selector will not be included in the result set. To demonstrate this select the paragraph with the class foo and use .nextUntil with a selector of bar .foo .nextUntil bar Only one paragraph is returned in the result set and the paragraph with the ID of bar is not included .foo .nextUntil bar 31 CHAPTER 2 COMMON JQUERY ACTIONS AND METHODS P To include the paragraph with an ID of bar you need to look at the element immediately following which is the form element in this case. Try the selector again using this updated code .foo .nextUntil form Now both following paragraphs are returned .foo .nextUntil form p p bar .prev .prevAll and .prevUntil The .prev .prevAll and .prevUntil Junctions work exactly like .next .nextAll and .nextUntil except they look at previous sibling elements rather than next sibling elements bar .prev p bar .prevAll p p bar .prevUntil .foo p .siblings To select sibling elements on both sides of an element use the .siblings method. This accepts a selector as an argument to limit what types of elements are returned. To match all