$('a.sameClass').nextAll().eq(0)

I want to select the first ul element after each anchor with the class some_anchors.

HTML

<a class="some_anchors">
</a>
<ul id="ul_1">
</ul>
...
<a class="some_anchors">
</a>
<ul id="ul_2">
</ul>
...
<a class="some_anchors">
</a>
<ul id="ul_3">
</ul>
...
<a class="some_anchors">
</a>
<ul id="ul_4">
</ul>
...

The following code returns only the first ul element:

console.log($(".some_anchors").nextAll('ul:first'));

How can I adjust the code so that it returns all ul elements (ul_1, ul_2, ul_3, ul_4)?

Use the nextAll method with a selector that selects all ul elements until the next a element with class some_anchors:

console.log($(".some_anchors").nextAll('ul:not(:has(a.some_anchors))'));

This will select all ul elements that do not have an a element with class some_anchors between them and the previous a element with class some_anchors.