Select all div elements in DOM after element?

I run something like this to select all div elements in the DOM (and this is good for me):

var $mySelection=$("#wrapper").find('div').not("#main-content, #etc")

How can I select all div elements in the DOM after some div instead?

+3
source share
3 answers

If you really mean all the <div>elements in the DOM after the starting point, you first need to find the nested of all your next siblings, then you will need to get the actual next siblings that are <div>elements.

var divs = $('#wrapper').nextAll().find('div');
divs = divs.add('#wrapper ~ div');
+2
source
$('div#id').nextAll(selector);

. nextAll ()

Hope this helps.

+3
source

$('div#wrapper ~ div')

, .not("#main-content, #etc"). , . , not selector

$('div#wrapper ~ div:not(#main-content, #etc)')
0
source

Source: https://habr.com/ru/post/1775704/


All Articles