-
Notifications
You must be signed in to change notification settings - Fork 264
/
Copy pathodd.xml
47 lines (47 loc) · 1.44 KB
/
odd.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
41
42
43
44
45
46
47
<?xml version="1.0"?>
<entry type="method" name="odd" return="jQuery">
<title>.odd()</title>
<signature>
<added>3.5</added>
</signature>
<desc>Reduce the set of matched elements to the odd ones in the set, numbered from zero.</desc>
<longdesc>
<p>Given a jQuery object that represents a set of DOM elements, the <code>.odd()</code> method constructs a new jQuery object from the odd elements in that set. Counting starts from zero!</p>
<p>Consider a page with a simple list on it:</p>
<pre><code>
<ul>
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
<li>list item 4</li>
<li>list item 5</li>
</ul>
</code></pre>
<p>We can apply this method to the set of list items:</p>
<pre><code>
$( "li" ).odd().css( "background-color", "red" );
</code></pre>
<p>The result of this call is a red background for the second & 4th items.</p>
</longdesc>
<example>
<desc>Highlight the odd items in a list.</desc>
<css><![CDATA[
.highlight {
background-color: yellow;
}
]]></css>
<code><![CDATA[
$( "ul li" ).odd().addClass( "highlight" );
]]></code>
<html><![CDATA[
<ul>
<li>Look:</li>
<li>This is some text in a list.</li>
<li>This is a note about it.</li>
<li>This is another note about it.</li>
</ul>
]]></html>
</example>
<category slug="traversing/filtering"/>
<category slug="version/3.5"/>
</entry>