jquery nextAll() method


  Translation results:

next

#英[nekst] 美[nɛkst]

adj. Immediately after; second to; close to; immediately adjacent

adv.Go on;then;behind;sequentially

n.next;next one

prep.Close;behind;next door to…

all

English[ɔ:l] American[ɔl]

adj. All; all; various; extreme, as much as possible

pron.all;everything;everyone,everything;all circumstances

adv.entirely;completely;every;very

n.all;[ Often used as A-] whole; [often used with my, your, his, her, etc.] everything that (someone) has


jquery nextAll() methodsyntax

Function: nextAll() obtains all following sibling elements of each element in the matching element set. Filtering by the selector is optional.

Syntax: .nextAll(selector)

Parameters:

Parameter Description
selector String value, containing the selector expression used to match elements.

Description: Given a jQuery object that represents a collection of DOM elements, the .nextAll() method allows us to search the DOM tree for elements following Sibling elements and constructs a new jQuery object with the matching element. The method accepts an optional selector expression of the same type that I passed into the $() function. If you apply a selector, elements will be filtered by detecting whether they match.

jquery nextAll() methodexample

<!DOCTYPE html>
<html>
<head>
  <style>
  div { width: 80px; height: 80px; background: #abc; 
        border: 2px solid black; margin: 10px; float: left; }
  div.after { border-color: red; }
  </style>
  <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
</head>

<body>
  <div>first</div>
  <div>sibling<div>child</div></div>
  <div>sibling</div>
  <div>sibling</div>
<script>
$("div:first").nextAll().addClass("after");
</script>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A