forked from jquery/api.jquery.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheven-selector.xml
40 lines (40 loc) · 1.58 KB
/
even-selector.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?xml version="1.0"?>
<entry type="selector" name="even" return="" deprecated="3.4">
<title>:even Selector</title>
<sample>:even</sample>
<signature>
<added>1.0</added>
</signature>
<desc>Selects even elements, zero-indexed. See also <a href="/odd-selector/"><code>:odd</code></a>.</desc>
<longdesc>
<div class="warning">
<p><strong>As of jQuery 3.4</strong>, the <code>:even</code> pseudo-class is deprecated. Remove it from your selectors and filter the results later using <a href="/even/"><code>.even()</code></a> (available in jQuery 3.5.0 or newer).</p>
</div>
<p>In particular, note that the <em>0-based indexing</em> means that, counter-intuitively, <code>:even</code> selects the first element, third element, and so on within the matched set.</p>
</longdesc>
<note id="jquery-selector-extension" type="additional" data-selector=":even"/>
<note id="document-order" type="additional"/>
<example>
<desc>Finds even table rows, matching the first, third and so on (index 0, 2, 4 etc.).</desc>
<code><![CDATA[
$( "tr:even" ).css( "background-color", "#bbf" );
]]></code>
<css><![CDATA[
table {
background: #eee;
}
]]></css>
<html><![CDATA[
<table border="1">
<tr><td>Row with Index #0</td></tr>
<tr><td>Row with Index #1</td></tr>
<tr><td>Row with Index #2</td></tr>
<tr><td>Row with Index #3</td></tr>
</table>
]]></html>
</example>
<category slug="selectors/basic-filter-selectors"/>
<category slug="selectors/jquery-selector-extensions"/>
<category slug="version/1.0"/>
<category slug="deprecated/deprecated-3.4"/>
</entry>