8000 Added grunt xmltidy task and used it to tidy all entries · LaserMoai/api.jquery.com@96f3fec · GitHub
Skip to content

Commit 96f3fec

Browse files
committed
Added grunt xmltidy task and used it to tidy all entries
1 parent 7066965 commit 96f3fec

292 files changed

Lines changed: 6673 additions & 6375 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

entries/add.xml

Lines changed: 66 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<entry type='method' name="add" return="jQuery">
1+
<?xml version="1.0"?>
2+
<entry type="method" name="add" return="jQuery">
23
<title>.add()</title>
34
<signature>
45
<added>1.0</added>
@@ -34,51 +35,64 @@
3435
</argument>
3536
</signature>
3637
<desc>Add elements to the set of matched elements.</desc>
37-
<longdesc><p>Given a jQuery object that represents a set of DOM elements, the <code>.add()</code> method constructs a new jQuery object from the union of those elements and the ones passed into the method. The argument to <code>.add()</code> can be pretty much anything that <code>$()</code> accepts, including a jQuery selector expression, references to DOM elements, or an HTML snippet.</p>
38-
<p>The updated set of elements can be used in a following (chained) method, or assigned to a variable for later use. For example:</p>
39-
<pre><code>
38+
<longdesc>
39+
<p>Given a jQuery object that represents a set of DOM elements, the <code>.add()</code> method constructs a new jQuery object from the union of those elements and the ones passed into the method. The argument to <code>.add()</code> can be pretty much anything that <code>$()</code> accepts, including a jQuery selector expression, references to DOM elements, or an HTML snippet.</p>
40+
<p>The updated set of elements can be used in a following (chained) method, or assigned to a variable for later use. For example:</p>
41+
<pre>
42+
<code>
4043
$("p").add("div").addClass("widget");
4144
var pdiv = $("p").add("div");
42-
</code></pre>
43-
<p>The following will <em>not</em> save the added elements, because the <code>.add()</code> method creates a new set and leaves the original set in pdiv unchanged:</p>
44-
<pre><code>
45+
</code>
46+
</pre>
47+
<p>The following will <em>not</em> save the added elements, because the <code>.add()</code> method creates a new set and leaves the original set in pdiv unchanged:</p>
48+
<pre>
49+
<code>
4550
var pdiv = $("p");
4651
pdiv.add("div"); // WRONG, pdiv will not change
47-
</code></pre>
48-
<p>Consider a page with a simple list and a paragraph following it:</p>
49-
<pre><code>&lt;ul&gt;
52+
</code>
53+
</pre>
54+
<p>Consider a page with a simple list and a paragraph following it:</p>
55+
<pre>
56+
<code>&lt;ul&gt;
5057
&lt;li&gt;list item 1&lt;/li&gt;
5158
&lt;li&gt;list item 2&lt;/li&gt;
5259
&lt;li&gt;list item 3&lt;/li&gt;
5360
&lt;/ul&gt;
54-
&lt;p&gt;a paragraph&lt;/p&gt;</code></pre>
55-
<p>We can select the list items and then the paragraph by using either a selector or a reference to the DOM element itself as the <code>.add()</code> method's argument:</p>
56-
<pre><code>$('li').add('p').css('background-color', 'red');</code></pre>
57-
<p>Or:</p>
58-
<pre><code>$('li').add(document.getElementsByTagName('p')[0])
59-
.css('background-color', 'red');</code></pre>
60-
<p>The result of this call is a red background behind all four elements.
61+
&lt;p&gt;a paragraph&lt;/p&gt;</code>
62+
</pre>
63+
<p>We can select the list items and then the paragraph by using either a selector or a reference to the DOM element itself as the <code>.add()</code> method's argument:</p>
64+
<pre>
65+
<code>$('li').add('p').css('background-color', 'red');</code>
66+
</pre>
67+
<p>Or:</p>
68+
<pre>
69+
<code>$('li').add(document.getElementsByTagName('p')[0])
70+
.css('background-color', 'red');</code>
71+
</pre>
72+
<p>The result of this call is a red background behind all four elements.
6173
Using an HTML snippet as the <code>.add()</code> method's argument (as in the third version), we can create additional elements on the fly and add those elements to the matched set of elements. Let's say, for example, that we want to alter the background of the list items along with a newly created paragraph:</p>
62-
<pre><code>$('li').add('&lt;p id="new"&gt;new paragraph&lt;/p&gt;')
63-
.css('background-color', 'red');</code></pre>
64-
<p>Although the new paragraph has been created and its background color changed, it still does not appear on the page. To place it on the page, we could add one of the insertion methods to the chain.</p>
65-
<p>As of jQuery 1.4 the results from .add() will always be returned in document order (rather than a simple concatenation).</p>
66-
<p><strong>Note:</strong> To reverse the <code>.add()</code> you can use <a href="http://api.jquery.com/not"><code>.not( elements | selector )</code></a> to remove elements from the jQuery results, or <a href="http://api.jquery.com/end"><code>.end()</code></a> to return to the selection before you added.</p>
67-
</longdesc>
68-
<example>
69-
<desc>Finds all divs and makes a border. Then adds all paragraphs to the jQuery object to set their backgrounds yellow.</desc>
70-
<code><![CDATA[
74+
<pre>
75+
<code>$('li').add('&lt;p id="new"&gt;new paragraph&lt;/p&gt;')
76+
.css('background-color', 'red');</code>
77+
</pre>
78+
<p>Although the new paragraph has been created and its background color changed, it still does not appear on the page. To place it on the page, we could add one of the insertion methods to the chain.</p>
79+
<p>As of jQuery 1.4 the results from .add() will always be returned in document order (rather than a simple concatenation).</p>
80+
<p><strong>Note:</strong> To reverse the <code>.add()</code> you can use <a href="http://api.jquery.com/not"><code>.not( elements | selector )</code></a> to remove elements from the jQuery results, or <a href="http://api.jquery.com/end"><code>.end()</code></a> to return to the selection before you added.</p>
81+
</longdesc>
82+
<example>
83+
<desc>Finds all divs and makes a border. Then adds all paragraphs to the jQuery object to set their backgrounds yellow.</desc>
84+
<code><![CDATA[
7185
7286
$("div").css("border", "2px solid red")
7387
.add("p")
7488
.css("background", "yellow");
7589
]]></code>
76-
<css><![CDATA[
90+
<css><![CDATA[
7791
div { width:60px; height:60px; margin:10px; float:left; }
7892
p { clear:left; font-weight:bold; font-size:16px;
7993
color:blue; margin:0 10px; padding:2px; }
8094
]]></css>
81-
<html><![CDATA[<div></div>
95+
<html><![CDATA[<div></div>
8296
8397
<div></div>
8498
<div></div>
@@ -87,31 +101,31 @@ $("div").css("border", "2px solid red")
87101
<div></div>
88102
89103
<p>Added this... (notice no border)</p>]]></html>
90-
</example>
91-
<example>
92-
<desc>Adds more elements, matched by the given expression, to the set of matched elements.</desc>
93-
<code><![CDATA[$("p").add("span").css("background", "yellow");]]></code>
94-
<html><![CDATA[<p>Hello</p><span>Hello Again</span>]]></html>
95-
</example>
96-
<example>
97-
<desc>Adds more elements, created on the fly, to the set of matched elements.</desc>
98-
<code><![CDATA[$("p").clone().add("<span>Again</span>").appendTo(document.body);]]></code>
99-
<html><![CDATA[<p>Hello</p>]]></html>
100-
</example>
101-
<example>
102-
<desc>Adds one or more Elements to the set of matched elements.</desc>
103-
<code><![CDATA[$("p").add(document.getElementById("a")).css("background", "yellow");]]></code>
104-
<html><![CDATA[<p>Hello</p><span id="a">Hello Again</span>]]></html>
105-
</example>
106-
<example>
107-
<desc>Demonstrates how to add (or push) elements to an existing collection</desc>
108-
<code><![CDATA[var collection = $("p");
104+
</example>
105+
<example>
106+
<desc>Adds more elements, matched by the given expression, to the set of matched elements.</desc>
107+
<code><![CDATA[$("p").add("span").css("background", "yellow");]]></code>
108+
<html><![CDATA[<p>Hello</p><span>Hello Again</span>]]></html>
109+
</example>
110+
<example>
111+
<desc>Adds more elements, created on the fly, to the set of matched elements.</desc>
112+
<code><![CDATA[$("p").clone().add("<span>Again</span>").appendTo(document.body);]]></code>
113+
<html><![CDATA[<p>Hello</p>]]></html>
114+
</example>
115+
<example>
116+
<desc>Adds one or more Elements to the set of matched elements.</desc>
117+
<code><![CDATA[$("p").add(document.getElementById("a")).css("background", "yellow");]]></code>
118+
<html><![CDATA[<p>Hello</p><span id="a">Hello Again</span>]]></html>
119+
</example>
120+
<example>
121+
<desc>Demonstrates how to add (or push) elements to an existing collection</desc>
122+
<code><![CDATA[var collection = $("p");
109123
// capture the new collection
110124
collection = collection.add(document.getElementById("a"));
111125
collection.css("background", "yellow");]]></code>
112-
<html><![CDATA[<p>Hello</p><span id="a">Hello Again</span>]]></html>
113-
</example>
114-
<category slug="traversing/miscellaneous-traversal"/>
115-
<category slug="version/1.0"/>
116-
<category slug="version/1.4"/>
126+
<html><![CDATA[<p>Hello</p><span id="a">Hello Again</span>]]></html>
127+
</example>
128+
<category slug="traversing/miscellaneous-traversal"/>
129+
<category slug="version/1.0"/>
130+
<category slug="version/1.4"/>
117131
</entry>

entries/addClass.xml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<entry type='method' name="addClass" return="jQuery">
1+
<?xml version="1.0"?>
2+
<entry type="method" name="addClass" return="jQuery">
23
<title>.addClass()</title>
34
<signature>
45
<added>1.0</added>
@@ -13,52 +14,52 @@
1314
</argument>
1415
</signature>
1516
<desc>Adds the specified class(es) to each of the set of matched elements.</desc>
16-
<longdesc><p>It's important to note that this method does not replace a class. It simply adds the class, appending it to any which may already be assigned to the elements.</p>
17-
<p>More than one class may be added at a time, separated by a space, to the set of matched elements, like so:</p>
18-
<pre>$("p").addClass("myClass yourClass");</pre>
19-
<p>This method is often used with <code>.removeClass()</code> to switch elements' classes from one to another, like so:</p>
20-
<pre>$("p").removeClass("myClass noClass").addClass("yourClass");</pre>
21-
<p>Here, the <code>myClass</code> and <code>noClass</code> classes are removed from all paragraphs, while <code>yourClass</code> is added.</p>
22-
<p>As of jQuery 1.4, the <code>.addClass()</code> method's argument can receive a function.</p>
23-
<pre>$("ul li:last").addClass(function(index) {
17+
<longdesc>
18+
<p>It's important to note that this method does not replace a class. It simply adds the class, appending it to any which may already be assigned to the elements.</p>
19+
<p>More than one class may be added at a time, separated by a space, to the set of matched elements, like so:</p>
20+
<pre>$("p").addClass("myClass yourClass");</pre>
21+
<p>This method is often used with <code>.removeClass()</code> to switch elements' classes from one to another, like so:</p>
22+
<pre>$("p").removeClass("myClass noClass").addClass("yourClass");</pre>
23+
<p>Here, the <code>myClass</code> and <code>noClass</code> classes are removed from all paragraphs, while <code>yourClass</code> is added.</p>
24+
<p>As of jQuery 1.4, the <code>.addClass()</code> method's argument can receive a function.</p>
25+
<pre>$("ul li:last").addClass(function(index) {
2426
return "item-" + index;
2527
});</pre>
26-
<p>Given an unordered list with five <code>&lt;li&gt;</code> elements, this example adds the class "item-4" to the last <code>&lt;li&gt;</code>.</p>
27-
28-
</longdesc>
29-
<example>
30-
<desc>Adds the class "selected" to the matched elements.</desc>
31-
<code><![CDATA[
28+
<p>Given an unordered list with five <code>&lt;li&gt;</code> elements, this example adds the class "item-4" to the last <code>&lt;li&gt;</code>.</p>
29+
</longdesc>
30+
<example>
31+
<desc>Adds the class "selected" to the matched elements.</desc>
32+
<code><![CDATA[
3233
$("p:last").addClass("selected");
3334
]]></code>
34-
<css><![CDATA[
35+
<css><![CDATA[
3536
p { margin: 8px; font-size:16px; }
3637
.selected { color:blue; }
3738
.highlight { background:yellow; }
3839
]]></css>
39-
<html><![CDATA[
40+
<html><![CDATA[
4041
<p>Hello</p>
4142
<p>and</p>
4243
<p>Goodbye</p>
4344
]]></html>
44-
</example>
45-
<example>
46-
<desc>Adds the classes "selected" and "highlight" to the matched elements.</desc>
47-
<code><![CDATA[
45+
</example>
46+
<example>
47+
<desc>Adds the classes "selected" and "highlight" to the matched elements.</desc>
48+
<code><![CDATA[
4849
$("p:last").addClass("selected highlight");
4950
]]></code>
50-
<css><![CDATA[
51+
<css><![CDATA[
5152
p { margin: 8px; font-size:16px; }
5253
.selected { color:red; }
5354
.highlight { background:yellow; }
5455
]]></css>
55-
<html><![CDATA[<p>Hello</p>
56+
<html><![CDATA[<p>Hello</p>
5657
<p>and</p>
5758
<p>Goodbye</p>]]></html>
58-
</example>
59-
<example>
60-
<desc>Pass in a function to <code>.addClass()</code> to add the "green" class to a div that already has a "red" class.</desc>
61-
<code><![CDATA[
59+
</example>
60+
<example>
61+
<desc>Pass in a function to <code>.addClass()</code> to add the "green" class to a div that already has a "red" class.</desc>
62+
<code><![CDATA[
6263
$("div").addClass(function(index, currentClass) {
6364
var addedClass;
6465
@@ -70,23 +71,22 @@
7071
return addedClass;
7172
});
7273
]]></code>
73-
74-
<css><![CDATA[
74+
<css><![CDATA[
< 78E4 /td>
7575
div { background: white; }
7676
.red { background: red; }
7777
.red.green { background: green; }
7878
]]></css>
79-
<html><![CDATA[
79+
<html><![CDATA[
8080
<div>This div should be white</div>
8181
<div class="red">This div will be green because it now has the "green" and "red" classes.
8282
It would be red if the addClass function failed.</div>
8383
<div>This div should be white</div>
8484
<p>There are zero green divs</p>
8585
]]></html>
86-
</example>
87-
<category slug="attributes"/>
88-
<category slug="manipulation/class-attribute"/>
89-
<category slug="css"/>
90-
<category slug="version/1.0"/>
91-
<category slug="version/1.4"/>
86+
</example>
87+
<category slug="attributes"/>
88+
<category slug="manipulation/class-attribute"/>
89+
<category slug="css"/>
90+
<category slug="version/1.0"/>
91+
<category slug="version/1.4"/>
9292
</entry>

entries/after.xml

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<entry type='method' name="after" return="jQuery">
1+
<?xml version="1.0"?>
2+
<entry type="method" name="after" return="jQuery">
23
<title>.after()</title>
34
<signature>
45
<added>1.0</added>
@@ -16,29 +17,24 @@
1617
</argument>
1718
</signature>
1819
<desc>Insert content, specified by the parameter, after each element in the set of matched elements.</desc>
19-
<longdesc><p>The <code>.after()</code> and <code><a href='/insertAfter'>.insertAfter()</a></code> methods perform the same task. The major difference is in the syntax&#8212;specifically, in the placement of the content and target. With<code> .after()</code>, the selector expression preceding the method is the container after which the content is inserted. With <code>.insertAfter()</code>, on the other hand, the content precedes the method, either as a selector expression or as markup created on the fly, and it is inserted after the target container.</p>
20-
20+
<longdesc>
21+
<p>The <code>.after()</code> and <code><a href="/insertAfter">.insertAfter()</a></code> methods perform the same task. The major difference is in the syntax&#x2014;specifically, in the placement of the content and target. With<code> .after()</code>, the selector expression preceding the method is the container after which the content is inserted. With <code>.insertAfter()</code>, on the other hand, the content precedes the method, either as a selector expression or as markup created on the fly, and it is inserted after the target container.</p>
2122
<p>Using the following HTML:</p>
2223
<pre>&lt;div class="container"&gt;
2324
&lt;h2&gt;Greetings&lt;/h2&gt;
2425
&lt;div class="inner"&gt;Hello&lt;/div&gt;
2526
&lt;div class="inner"&gt;Goodbye&lt;/div&gt;
2627
&lt;/div&gt;</pre>
27-
2828
<p>Content can be created and then inserted after several elements at once:</p>
29-
3029
<pre>$('.inner').after('&lt;p&gt;Test&lt;/p&gt;');</pre>
31-
3230
<p>Each inner <code>&lt;div&gt;</code> element gets this new content:</p>
33-
3431
<pre>&lt;div class="container"&gt;
3532
&lt;h2&gt;Greetings&lt;/h2&gt;
3633
&lt;div class="inner"&gt;Hello&lt;/div&gt;
3734
&lt;p&gt;Test&lt;/p&gt;
3835
&lt;div class="inner"&gt;Goodbye&lt;/div&gt;
3936
&lt;p&gt;Test&lt;/p&gt;
4037
&lt;/div&gt;</pre>
41-
4238
<p>An element in the DOM can also be selected and inserted after another element:</p>
4339
<pre>$('.container').after($('h2'));</pre>
4440
<p>If an element selected this way is inserted elsewhere, it will be moved rather than cloned:</p>
@@ -77,26 +73,26 @@
7773
$('p').first().after($newdiv1, [newdiv2, existingdiv1]);
7874
</pre>
7975
<p>Since <code>.after()</code> can accept any number of additional arguments, the same result can be achieved by passing in the three <code>&lt;div&gt;</code>s as three separate arguments, like so: <code>$('p').first().after($newdiv1, newdiv2, existingdiv1)</code>. The type and number of arguments will largely depend on the elements that are collected in the code.</p>
80-
</longdesc>
76+
</longdesc>
8177
<example>
82-
<desc>Inserts some HTML after all paragraphs.</desc>
83-
<code><![CDATA[$("p").after("<b>Hello</b>");]]></code>
84-
<css><![CDATA[p { background:yellow; }]]></css>
85-
<html><![CDATA[<p>I would like to say: </p>]]></html>
78+
<desc>Inserts some HTML after all paragraphs.</desc>
79+
<code><![CDATA[$("p").after("<b>Hello</b>");]]></code>
80+
<css><![CDATA[p { background:yellow; }]]></css>
81+
<html><![CDATA[<p>I would like to say: </p>]]></html>
8682
</example>
8783
<example>
88-
<desc>Inserts a DOM element after all paragraphs.</desc>
89-
<code><![CDATA[$("p").after( document.createTextNode("Hello") );]]></code>
90-
<css><![CDATA[p { background:yellow; }]]></css>
91-
<html><![CDATA[<p>I would like to say: </p>]]></html>
84+
<desc>Inserts a DOM element after all paragraphs.</desc>
85+
<code><![CDATA[$("p").after( document.createTextNode("Hello") );]]></code>
86+
<css><![CDATA[p { background:yellow; }]]></css>
87+
<html><![CDATA[<p>I would like to say: </p>]]></html>
9288
</example>
9389
<example>
94-
<desc>Inserts a jQuery object (similar to an Array of DOM Elements) after all paragraphs.</desc>
95-
<code><![CDATA[$("p").after( $("b") );]]></code>
96-
<css><![CDATA[p { background:yellow; }]]></css>
97-
<html><![CDATA[<b>Hello</b><p>I would like to say: </p>]]></html>
90+
<desc>Inserts a jQuery object (similar to an Array of DOM Elements) after all paragraphs.</desc>
91+
<code><![CDATA[$("p").after( $("b") );]]></code>
92+
<css><![CDATA[p { background:yellow; }]]></css>
93+
<html><![CDATA[<b>Hello</b><p>I would like to say: </p>]]></html>
9894
</example>
99-
<category slug="manipulation/dom-insertion-outside"/>
100-
<category slug="version/1.0"/>
101-
<category slug="version/1.4"/>
95+
<category slug="manipulation/dom-insertion-outside"/>
96+
<category slug="version/1.0"/>
97+
<category slug="version/1.4"/>
10298
</entry>

0 commit comments

Comments
 (0)