.nextUntil()

In this chapter you will learn:

  1. Syntax and Description for .nextUntil()

Syntax and Description

.nextUntil(selector)

gets all following siblings of each element up to, but not including, the element matched by the selector. selector indicates where to stop matching following sibling elements.

Return value is the new jQuery object.

For the HTML elements below

<dl>//  j  a  v a  2 s  .c om
 <dt>term 1</dt>
 <dd>definition 1-a</dd>
 <dt id="term-2">term 2</dt>
 <dd>definition 2-a</dd>
 <dd>definition 2-b</dd>
 <dd>definition 2-c</dd>
 <dt>term 3</dt>
 <dd>definition 3-b</dd>
</dl>

The following code

$('#term-2').nextUntil('dt').css('background-color', 'red');

marks 2-a, 2-b, and 2-c.

Next chapter...

What you will learn in the next chapter:

  1. Syntax and Description for .not()
  2. Remove element by id
  3. Remove element by its style class