control-freak-ide/Control-Freak-Documentation/jQuery/docs/entries/nextAll.json
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

1 line
2.6 KiB
JSON

{"name":"nextAll","type":"method","title":".nextAll()","deprecated":null,"removed":null,"desc":"Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.","categories":["traversing/tree-traversal","version/1.2"],"entries":[{"return":"jQuery","signatures":{"added":"1.2","argument":{"desc":"A string containing a selector expression to match elements against.","name":"selector","optional":"true","type":"String"}},"examples":[{"desc":"Locate all the divs after the first and give them a class.","code":"\n$( \"div:first\" ).nextAll().addClass( \"after\" );\n","css":"\n div {\n width: 80px;\n height: 80px;\n background: #abc;\n border: 2px solid black;\n margin: 10px;\n float: left;\n }\n div.after {\n border-color: red;\n }\n","height":"150","html":"\n<div>first</div>\n<div>sibling<div>child</div></div>\n<div>sibling</div>\n<div>sibling</div>"},{"desc":"Locate all the paragraphs after the second child in the body and give them a class.","code":"\n$( \":nth-child(1)\" ).nextAll( \"p\" ).addClass( \"after\" );\n","css":"\n div, p {\n width: 60px;\n height: 60px;\n background: #abc;\n border: 2px solid black;\n margin: 10px;\n float: left;\n }\n .after {\n border-color: red;\n }\n","height":"200","html":"\n<p>p</p>\n<div>div</div>\n<p>p</p>\n<p>p</p>\n<div>div</div>\n<p>p</p>\n<div>div</div>\n"}],"longdesc":"\n <p>Given a jQuery object that represents a set of DOM elements, the <code>.nextAll()</code> method allows us to search through the successors of these elements in the DOM tree and construct a new jQuery object from the matching elements.</p>\n <p>The method optionally accepts a selector expression of the same type that we can pass to the <code>$()</code> function. If the selector is supplied, the elements will be filtered by testing whether they match it.</p>\n <p>Consider a page with a simple list on it:</p>\n <pre><code>\n&lt;ul&gt;\n &lt;li&gt;list item 1&lt;/li&gt;\n &lt;li&gt;list item 2&lt;/li&gt;\n &lt;li class=\"third-item\"&gt;list item 3&lt;/li&gt;\n &lt;li&gt;list item 4&lt;/li&gt;\n &lt;li&gt;list item 5&lt;/li&gt;\n&lt;/ul&gt;\n </code></pre>\n <p>If we begin at the third item, we can find the elements which come after it:</p>\n <pre><code>\n$( \"li.third-item\" ).nextAll().css( \"background-color\", \"red\" );\n </code></pre>\n <p>The result of this call is a red background behind items 4 and 5. Since we do not supply a selector expression, these following elements are unequivocally included as part of the object. If we had supplied one, the elements would be tested for a match before they were included.</p>\n "}]}