Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery - Select all elements after a certain element

I have a list similar to below and would like to only select all of the elements after the #everything_after element.

<div id="container">   <div class="something"></div>   <div class="something"></div>   <div class="something"></div>   <div class="something"></div>   <div class="something"></div>   <div id="everything_after"></div>   <div class="something"></div>   <div class="something"></div>   <div class="something"></div>   <div class="something"></div>   <div class="something"></div> </div> 
like image 842
jhanifen Avatar asked Apr 01 '11 21:04

jhanifen


People also ask

How to select elements using jQuery?

jQuery selectors are used to "find" (or select) HTML elements based on their name, id, classes, types, attributes, values of attributes and much more. It's based on the existing CSS Selectors, and in addition, it has some own custom selectors. All selectors in jQuery start with the dollar sign and parentheses: $().

What does nextAll do in jQuery?

jQuery nextAll() Method The nextAll() method returns all next sibling elements of the selected element. Sibling elements are elements that share the same parent. The DOM tree: This method traverse forward along siblings of DOM elements.

Can you use CSS selectors in jQuery for selecting elements?

jQuery uses CSS selector to select elements using CSS. Let us see an example to return a style property on the first matched element. The css( name ) method returns a style property on the first matched element.

What is the syntax of jQuery to select and handle elements?

Following is the basic syntax for selecting HTML elements and then performing some action on the selected element(s): $(document). ready(function(){ $(selector).


1 Answers

You can use nextAll to get the following divs.

Try:

$("#everything_after").nextAll(); 
like image 121
Chandu Avatar answered Oct 09 '22 07:10

Chandu