Skip to content

Commit ab8a2d3

Browse files
authored
removeClass: Separate the signature with no parameters
signatures until one read the description. Closes gh-1187
1 parent 2eec5a9 commit ab8a2d3

File tree

1 file changed

+194
-175
lines changed

1 file changed

+194
-175
lines changed

entries/removeClass.xml

Lines changed: 194 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,177 +1,196 @@
11
<?xml version="1.0"?>
2-
<entry type="method" name="removeClass" return="jQuery">
3-
<title>.removeClass()</title>
4-
<signature>
5-
<added>1.0</added>
6-
<argument name="className" optional="true" type="String">
7-
<desc>One or more space-separated classes to be removed from the class attribute of each matched element.</desc>
8-
</argument>
9-
</signature>
10-
<signature>
11-
<added>3.3</added>
12-
<argument name="classNames" type="Array">
13-
<desc>An array of classes to be removed from the class attribute of each matched element.</desc>
14-
</argument>
15-
</signature>
16-
<signature>
17-
<added>1.4</added>
18-
<argument name="function" type="Function">
19-
<argument name="index" type="Integer" />
20-
<argument name="className" type="String" />
21-
<return type="String" />
22-
<desc>A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments.</desc>
23-
</argument>
24-
</signature>
25-
<signature>
26-
<added>3.3</added>
27-
<argument name="function" type="Function">
28-
<argument name="index" type="Integer" />
29-
<argument name="className" type="String" />
30-
<return type="String" />
31-
<return type="Array" />
32-
<desc>A function returning one or more space-separated class names or an array of class names to be removed. Receives the index position of the element in the set and the old class value as arguments.</desc>
33-
</argument>
34-
</signature>
2+
<entries>
353
<desc>Remove a single class, multiple classes, or all classes from each element in the set of matched elements.</desc>
36-
<longdesc>
37-
<p>If a class name is included as a parameter, then only that class will be removed from the set of matched elements. If no classes are specified in the parameter, all classes will be removed.</p>
38-
<p>Before jQuery version 1.12/2.2, the <code>.removeClass()</code> method manipulated the <code>className</code> <em>property</em> of the selected elements, not the <code>class</code> <em>attribute</em>. Once the property was changed, it was the browser that updated the attribute accordingly. This means that when the <code>class</code> attribute was updated and the last class name was removed, the browser might have set the attribute's value to an empty string instead of removing the attribute completely. An implication of this behavior was that this method only worked for documents with HTML DOM semantics (e.g., not pure XML documents).</p>
39-
<p>As of jQuery 1.12/2.2, this behavior is changed to improve the support for XML documents, including SVG. Starting from this version, the <code>class</code> <em>attribute</em> is used instead. So, <code>.removeClass()</code> can be used on XML or SVG documents.</p>
40-
<p>More than one class may be removed at a time, separated by a space, from the set of matched elements, like so:</p>
41-
<pre><code>
42-
$( "p" ).removeClass( "myClass yourClass" )
43-
</code></pre>
44-
<p>This method is often used with <code>.addClass()</code> to switch elements' classes from one to another, like so:</p>
45-
<pre><code>
46-
$( "p" ).removeClass( "myClass noClass" ).addClass( "yourClass" );
47-
</code></pre>
48-
<p>Here, the <code>myClass</code> and <code>noClass</code> classes are removed from all paragraphs, while <code>yourClass</code> is added.</p>
49-
<p>To replace all existing classes with another class, we can use <code>.attr( "class", "newClass" )</code> instead.</p>
50-
<p>As of jQuery 1.4, the <code>.removeClass()</code> method allows us to indicate the class to be removed by passing in a function.</p>
51-
<pre><code>
52-
$( "li" ).last().removeClass(function() {
53-
return $( this ).prev().attr( "class" );
54-
});
55-
</code></pre>
56-
<p>This example removes the class name of the penultimate <code>&lt;li&gt;</code> from the last <code>&lt;li&gt;</code>.</p>
57-
</longdesc>
58-
<example>
59-
<desc>Remove the class 'blue' from the matched elements.</desc>
60-
<code><![CDATA[
61-
$( "p" ).even().removeClass( "blue" );
62-
]]></code>
63-
<css><![CDATA[
64-
p {
65-
margin: 4px;
66-
font-size: 16px;
67-
font-weight: bolder;
68-
}
69-
.blue {
70-
color: blue;
71-
}
72-
.under {
73-
text-decoration: underline;
74-
}
75-
.highlight {
76-
background: yellow;
77-
}
78-
]]></css>
79-
<html><![CDATA[
80-
<p class="blue under">Hello</p>
81-
<p class="blue under highlight">and</p>
82-
<p class="blue under">then</p>
83-
<p class="blue under">Goodbye</p>
84-
]]></html>
85-
</example>
86-
<example>
87-
<desc>Remove the class 'blue' and 'under' from the matched elements.</desc>
88-
<code><![CDATA[
89-
$( "p" ).odd().removeClass( "blue under" );
90-
]]></code>
91-
<css><![CDATA[
92-
p {
93-
margin: 4px;
94-
font-size: 16px;
95-
font-weight: bolder;
96-
}
97-
.blue {
98-
color: blue;
99-
}
100-
.under {
101-
text-decoration: underline;
102-
}
103-
.highlight {
104-
background: yellow;
105-
}
106-
]]></css>
107-
<html><![CDATA[
108-
<p class="blue under">Hello</p>
109-
<p class="blue under highlight">and</p>
110-
<p class="blue under">then</p>
111-
<p class="blue under">Goodbye</p>
112-
]]></html>
113-
</example>
114-
<example>
115-
<desc>Remove the class 'blue' and 'under' from the matched elements (3.3+ syntax).</desc>
116-
<code><![CDATA[
117-
$( "p" ).odd().removeClass( [ "blue", "under" ] );
118-
]]></code>
119-
<css><![CDATA[
120-
p {
121-
margin: 4px;
122-
font-size: 16px;
123-
font-weight: bolder;
124-
}
125-
.blue {
126-
color: blue;
127-
}
128-
.under {
129-
text-decoration: underline;
130-
}
131-
.highlight {
132-
background: yellow;
133-
}
134-
]]></css>
135-
<html><![CDATA[
136-
<p class="blue under">Hello</p>
137-
<p class="blue under highlight">and</p>
138-
<p class="blue under">then</p>
139-
<p class="blue under">Goodbye</p>
140-
]]></html>
141-
</example>
142-
<example>
143-
<desc>Remove all the classes from the matched elements.</desc>
144-
<code><![CDATA[
145-
$( "p" ).eq( 1 ).removeClass();
146-
]]></code>
147-
<css><![CDATA[
148-
p {
149-
margin: 4px;
150-
font-size: 16px;
151-
font-weight: bolder;
152-
}
153-
.blue {
154-
color: blue;
155-
}
156-
.under {
157-
text-decoration: underline;
158-
}
159-
.highlight {
160-
background: yellow;
161-
}
162-
]]></css>
163-
<html><![CDATA[
164-
<p class="blue under">Hello</p>
165-
<p class="blue under highlight">and</p>
166-
<p class="blue under">then</p>
167-
<p class="blue under">Goodbye</p>
168-
]]></html>
169-
</example>
170-
<category slug="attributes"/>
171-
<category slug="manipulation/class-attribute"/>
172-
<category slug="css"/>
173-
<category slug="version/1.0"/>
174-
<category slug="version/1.4"/>
175-
<category slug="version/1.12-and-2.2"/>
176-
<category slug="version/3.3"/>
177-
</entry>
4+
<entry type="method" name="removeClass" return="jQuery">
5+
<title>.removeClass( classes )</title>
6+
<signature>
7+
<added>1.0</added>
8+
<argument name="className" type="String">
9+
<desc>One or more space-separated classes to be removed from the class attribute of each matched element.</desc>
10+
</argument>
11+
</signature>
12+
<signature>
13+
<added>3.3</added>
14+
<argument name="classNames" type="Array">
15+
<desc>An array of classes to be removed from the class attribute of each matched element.</desc>
16+
</argument>
17+
</signature>
18+
<signature>
19+
<added>1.4</added>
20+
<argument name="function" type="Function">
21+
<argument name="index" type="Integer" />
22+
<argument name="className" type="String" />
23+
<return type="String" />
24+
<desc>A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments.</desc>
25+
</argument>
26+
</signature>
27+
<signature>
28+
<added>3.3</added>
29+
<argument name="function" type="Function">
30+
<argument name="index" type="Integer" />
31+
<argument name="className" type="String" />
32+
<return type="String" />
33+
<return type="Array" />
34+
<desc>A function returning one or more space-separated class names or an array of class names to be removed. Receives the index position of the element in the set and the old class value as arguments.</desc>
35+
</argument>
36+
</signature>
37+
<desc>Remove a single class or multiple classes from each element in the set of matched elements.</desc>
38+
<longdesc>
39+
<p>Before jQuery version 1.12/2.2, the <code>.removeClass()</code> method manipulated the <code>className</code> <em>property</em> of the selected elements, not the <code>class</code> <em>attribute</em>. Once the property was changed, it was the browser that updated the attribute accordingly. This means that when the <code>class</code> attribute was updated and the last class name was removed, the browser might have set the attribute's value to an empty string instead of removing the attribute completely. An implication of this behavior was that this method only worked for documents with HTML DOM semantics (e.g., not pure XML documents).</p>
40+
<p>As of jQuery 1.12/2.2, this behavior is changed to improve the support for XML documents, including SVG. Starting from this version, the <code>class</code> <em>attribute</em> is used instead. So, <code>.removeClass()</code> can be used on XML or SVG documents.</p>
41+
<p>More than one class may be removed at a time, separated by a space, from the set of matched elements, like so:</p>
42+
<pre><code>
43+
$( "p" ).removeClass( "myClass yourClass" )
44+
</code></pre>
45+
<p>This method is often used with <code>.addClass()</code> to switch elements' classes from one to another, like so:</p>
46+
<pre><code>
47+
$( "p" ).removeClass( "myClass noClass" ).addClass( "yourClass" );
48+
</code></pre>
49+
<p>Here, the <code>myClass</code> and <code>noClass</code> classes are removed from all paragraphs, while <code>yourClass</code> is added.</p>
50+
<p>To replace all existing classes with another class, we can use <code>.attr( "class", "newClass" )</code> instead.</p>
51+
<p>As of jQuery 1.4, the <code>.removeClass()</code> method allows us to indicate the class to be removed by passing in a function.</p>
52+
<pre><code>
53+
$( "li" ).last().removeClass(function() {
54+
return $( this ).prev().attr( "class" );
55+
});
56+
</code></pre>
57+
<p>This example removes the class name of the penultimate <code>&lt;li&gt;</code> from the last <code>&lt;li&gt;</code>.</p>
58+
</longdesc>
59+
<example>
60+
<desc>Remove the class 'blue' from the matched elements.</desc>
61+
<code><![CDATA[
62+
$( "p" ).even().removeClass( "blue" );
63+
]]></code>
64+
<css><![CDATA[
65+
p {
66+
margin: 4px;
67+
font-size: 16px;
68+
font-weight: bolder;
69+
}
70+
.blue {
71+
color: blue;
72+
}
73+
.under {
74+
text-decoration: underline;
75+
}
76+
.highlight {
77+
background: yellow;
78+
}
79+
]]></css>
80+
<html><![CDATA[
81+
<p class="blue under">Hello</p>
82+
<p class="blue under highlight">and</p>
83+
<p class="blue under">then</p>
84+
<p class="blue under">Goodbye</p>
85+
]]></html>
86+
</example>
87+
<example>
88+
<desc>Remove the class 'blue' and 'under' from the matched elements.</desc>
89+
<code><![CDATA[
90+
$( "p" ).odd().removeClass( "blue under" );
91+
]]></code>
92+
<css><![CDATA[
93+
p {
94+
margin: 4px;
95+
font-size: 16px;
96+
font-weight: bolder;
97+
}
98+
.blue {
99+
color: blue;
100+
}
101+
.under {
102+
text-decoration: underline;
103+
}
104+
.highlight {
105+
background: yellow;
106+
}
107+
]]></css>
108+
<html><![CDATA[
109+
<p class="blue under">Hello</p>
110+
<p class="blue under highlight">and</p>
111+
<p class="blue under">then</p>
112+
<p class="blue under">Goodbye</p>
113+
]]></html>
114+
</example>
115+
<example>
116+
<desc>Remove the class 'blue' and 'under' from the matched elements (3.3+ syntax).</desc>
117+
<code><![CDATA[
118+
$( "p" ).odd().removeClass( [ "blue", "under" ] );
119+
]]></code>
120+
<css><![CDATA[
121+
p {
122+
margin: 4px;
123+
font-size: 16px;
124+
font-weight: bolder;
125+
}
126+
.blue {
127+
color: blue;
128+
}
129+
.under {
130+
text-decoration: underline;
131+
}
132+
.highlight {
133+
background: yellow;
134+
}
135+
]]></css>
136+
<html><![CDATA[
137+
<p class="blue under">Hello</p>
138+
<p class="blue under highlight">and</p>
139+
<p class="blue under">then</p>
140+
<p class="blue under">Goodbye</p>
141+
]]></html>
142+
</example>
143+
<category slug="attributes"/>
144+
<category slug="manipulation/class-attribute"/>
145+
<category slug="css"/>
146+
<category slug="version/1.0"/>
147+
<category slug="version/1.4"/>
148+
<category slug="version/1.12-and-2.2"/>
149+
<category slug="version/3.3"/>
150+
</entry>
151+
152+
<entry type="method" name="removeClass" return="jQuery">
153+
<title>.removeClass()</title>
154+
<signature>
155+
<added>1.0</added>
156+
</signature>
157+
<desc>Remove all classes from each matched element.</desc>
158+
<longdesc>
159+
<p>Before jQuery version 1.12/2.2, the <code>.removeClass()</code> method manipulated the <code>className</code> <em>property</em> of the selected elements, not the <code>class</code> <em>attribute</em>. Once the property was changed, it was the browser that updated the attribute accordingly. This means that when the <code>class</code> attribute was updated and the last class name was removed, the browser might have set the attribute's value to an empty string instead of removing the attribute completely. An implication of this behavior was that this method only worked for documents with HTML DOM semantics (e.g., not pure XML documents).</p>
160+
<p>As of jQuery 1.12/2.2, this behavior is changed to improve the support for XML documents, including SVG. Starting from this version, the <code>class</code> <em>attribute</em> is used instead. So, <code>.removeClass()</code> can be used on XML or SVG documents.</p>
161+
</longdesc>
162+
<example>
163+
<desc>Remove all the classes from the matched elements.</desc>
164+
<code><![CDATA[
165+
$( "p" ).eq( 1 ).removeClass();
166+
]]></code>
167+
<css><![CDATA[
168+
p {
169+
margin: 4px;
170+
font-size: 16px;
171+
font-weight: bolder;
172+
}
173+
.blue {
174+
color: blue;
175+
}
176+
.under {
177+
text-decoration: underline;
178+
}
179+
.highlight {
180+
background: yellow;
181+
}
182+
]]></css>
183+
<html><![CDATA[
184+
<p class="blue under">Hello</p>
185+
<p class="blue under highlight">and</p>
186+
<p class="blue under">then</p>
187+
<p class="blue under">Goodbye</p>
188+
]]></html>
189+
</example>
190+
<category slug="attributes"/>
191+
<category slug="manipulation/class-attribute"/>
192+
<category slug="css"/>
193+
<category slug="version/1.0"/>
194+
<category slug="version/1.12-and-2.2"/>
195+
</entry>
196+
</entries>

0 commit comments

Comments
 (0)