javascriptjquerynextuntil

jQuery, nextUntil(), if element is not a paragraph


I wanna use nextUntil() to make all p's orange which are directly following a h2.first till any other html tag than p arrives.

<h2 class="first">Lorem ipsum</h2>
<p>Lorem ipsum</p>
<p>Lorem ipsum</p>
<p>Lorem ipsum</p>
<ul>
  <li>Lorem ipsum</li>
  <li>Lorem ipsum</li>
  <li>Lorem ipsum</li>
</ul>
<h2>
<p>Lorem ipsum</p>
<p>Lorem ipsum</p>
<p>Lorem ipsum</p>

So in this case the pragraphs are followed by an unordered list. But it could also be any other html tag. My problem is to express "any other html tag than p". Is there someone out there, who knows the answer?

-> nextUntil(**'any other html tag than p'**, 'p')

Thanks a lot in advance!


Solution

  • Not can help you to do so. You can use this :

    nextUntil(":not(p)");