Skip to content

Commit 69cc61f

Browse files
committed
Filter: Explain behavior on text and comment nodes
Closes jquery#968
1 parent 9fef869 commit 69cc61f

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

entries/filter.xml

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ $( "li" )
7676
.css( "background-color", "red" );
7777
</code></pre>
7878
<p>This alteration to the code will cause the third and sixth list items to be highlighted, as it uses the modulus operator (<code>%</code>) to select every item with an <code>index</code> value that, when divided by 3, has a remainder of <code>2</code>.</p>
79+
<p><strong>Note:</strong> When a CSS selector string is passed to <code>.filter()</code>, text and comment nodes will always be removed from the resulting jQuery object during the filtering process. When a specific node or array of nodes are provided, a text or comment node will be included in the resulting jQuery object only if it matches one of the nodes in the filtering array.</p>
7980
<note id="svg-support" type="additional"/>
8081
</longdesc>
8182
<example>

entries/not.xml

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ $( "li" ).not( document.getElementById( "notli" ) )
6161
</code></pre>
6262
<p>This statement changes the color of items 1, 2, 4, and 5. We could have accomplished the same thing with a simpler jQuery expression, but this technique can be useful when, for example, other libraries provide references to plain DOM nodes.</p>
6363
<p>As of jQuery 1.4, the <code>.not()</code> method can take a function as its argument in the same way that <code>.filter()</code> does. Elements for which the function returns <code>true</code> are excluded from the filtered set; all other elements are included.</p>
64+
<p><strong>Note:</strong> When a CSS selector string is passed to <code>.not()</code>, text and comment nodes will always be removed from the resulting jQuery object during the filtering process. When a specific node or array of nodes are provided, text or comment nodes will only be removed from the jQuery object if they match one of the nodes in the filtering array.</p>
6465
</longdesc>
6566
<example>
6667
<desc>Adds a border to divs that are not green or blue.</desc>

0 commit comments

Comments
 (0)