.nextUntil() method gets all following siblings of each element up to

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>/*  w ww . j a  v  a2s . c  o m*/
 <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.





















Home »
  jQuery »
    jQuery Tutorial »




Basics
Selector
DOM
Event
Effect
Utilities