nextUntil ([exp | ele] [, fil]) Find all siblings after the current element, that element until the first match.

nextUntil ([exp | it] [, fil])

Outline

Find all siblings after the current element until it encounters an element that matches so far.

Given a jQuery object that represents a set of DOM elements, .nextUntil () method will also allow us searched all the elements where the DOM tree, until it encounters an element provided with time parameter matching will stop. This new jQuery object contains all the following siblings found, but does not include the selector to match the elements.

If you do not choose to match, or did not provide arguments, like all siblings will be selected at the back. This is like using .nextAll not provide parameters () effect. Marble platform accuracy class

parameter

[expr][,filter]String,StringV1.4

expr : for screening ancestor element of expression.

filter : a string containing a selection expression matching elements.

[element][,filter]DOMElement,StringV1.6

Element : Screening for ancestor elements in the DOM element.

filter : a string containing a selection expression matching elements.

Examples

description:

To # term-2 pre-dt elements until later with a red background

HTML code:
<dl>
  <dt id="term-1" >term 1</dt>
  <dd>definition 1-a</dd>
  <dd>definition 1-b</dd>
  <dd>definition 1-c</dd>
  <dd>definition 1-d</dd>

  <dt id="term-2">term 2</dt>
  <dd>definition 2-a</dd>
  <dd>definition 2-b</dd>
  <dd>definition 2-c</dd>

  <dt id="term-3" >term 3</dt>
  <dd>definition 3-a</dd>
  <dd>definition 3-b</dd>
</dl>
jQuery code:
$('#term-2').nextUntil('dt').css('background-color', 'red');
      
var term3 = document.getElementById("term-3");
$("#term-1").nextUntil(term3, "dd").css("color", "green");
result:
term 1
definition 1-a
definition 1-b
definition 1-c
definition 1-d
term 2
definition 2-a
definition 2-b
definition 2-c
term 3
definition 3-a
definition 3-b

 

Guess you like

Origin www.cnblogs.com/furuihua/p/12015845.html