Permalink
Browse files

Added grunt xmltidy task and used it to tidy all entries

  • Loading branch information...
1 parent 7066965 commit 96f3fecb0230c787047f8a1826504421e47b079a @rdworth rdworth committed Jun 8, 2012
Showing with 6,673 additions and 6,375 deletions.
  1. +66 −52 entries/add.xml
  2. +36 −36 entries/addClass.xml
  3. +20 −24 entries/after.xml
  4. +12 −13 entries/ajaxComplete.xml
  5. +11 −11 entries/ajaxError.xml
  6. +11 −10 entries/ajaxSend.xml
  7. +4 −3 entries/ajaxStart.xml
  8. +4 −3 entries/ajaxStop.xml
  9. +5 −7 entries/ajaxSuccess.xml
  10. +12 −10 entries/all-selector.xml
  11. +10 −7 entries/andSelf.xml
  12. +102 −117 entries/animate.xml
  13. +9 −7 entries/animated-selector.xml
  14. +40 −39 entries/append.xml
  15. +14 −11 entries/appendTo.xml
  16. +100 −98 entries/attr.xml
  17. +20 −17 entries/attribute-contains-prefix-selector.xml
  18. +21 −16 entries/attribute-contains-selector.xml
  19. +21 −16 entries/attribute-contains-word-selector.xml
  20. +19 −16 entries/attribute-ends-with-selector.xml
  21. +6 −5 entries/attribute-equals-selector.xml
  22. +26 −23 entries/attribute-not-equal-selector.xml
  23. +18 −13 entries/attribute-starts-with-selector.xml
  24. +25 −23 entries/before.xml
  25. +30 −35 entries/bind.xml
  26. +14 −12 entries/blur.xml
  27. +14 −14 entries/button-selector.xml
  28. +6 −6 entries/callbacks.add.xml
  29. +6 −5 entries/callbacks.disable.xml
  30. +3 −2 entries/callbacks.empty.xml
  31. +3 −2 entries/callbacks.fire.xml
  32. +3 −2 entries/callbacks.fireWith.xml
  33. +6 −5 entries/callbacks.fired.xml
  34. +8 −7 entries/callbacks.has.xml
  35. +4 −5 entries/callbacks.lock.xml
  36. +8 −7 entries/callbacks.locked.xml
  37. +8 −8 entries/callbacks.remove.xml
  38. +29 −29 entries/change.xml
  39. +16 −12 entries/checkbox-selector.xml
  40. +18 −13 entries/checked-selector.xml
  41. +10 −6 entries/child-selector.xml
  42. +31 −28 entries/children.xml
  43. +24 −20 entries/class-selector.xml
  44. +22 −19 entries/clearQueue.xml
  45. +38 −36 entries/click.xml
  46. +36 −31 entries/clone.xml
  47. +116 −114 entries/closest.xml
  48. +13 −13 entries/contains-selector.xml
  49. +12 −11 entries/contents.xml
  50. +14 −10 entries/context.xml
  51. +67 −67 entries/css.xml
  52. +79 −83 entries/data.xml
  53. +20 −19 entries/dblclick.xml
  54. +6 −3 entries/deferred.always.xml
  55. +15 −14 entries/deferred.done.xml
  56. +10 −7 entries/deferred.fail.xml
  57. +4 −3 entries/deferred.isRejected.xml
  58. +4 −4 entries/deferred.isResolved.xml
  59. +3 −2 entries/deferred.notify.xml
  60. +3 −2 entries/deferred.notifyWith.xml
  61. +6 −5 entries/deferred.pipe.xml
  62. +5 −2 entries/deferred.progress.xml
  63. +13 −13 entries/deferred.promise.xml
  64. +7 −5 entries/deferred.reject.xml
  65. +7 −4 entries/deferred.rejectWith.xml
  66. +6 −4 entries/deferred.resolve.xml
  67. +7 −5 entries/deferred.resolveWith.xml
  68. +3 −2 entries/deferred.state.xml
  69. +12 −9 entries/deferred.then.xml
  70. +17 −14 entries/delay.xml
  71. +17 −23 entries/delegate.xml
  72. +12 −9 entries/dequeue.xml
  73. +9 −6 entries/descendant-selector.xml
  74. +8 −5 entries/detach.xml
  75. +66 −65 entries/die.xml
  76. +11 −6 entries/disabled-selector.xml
  77. +26 −23 entries/each.xml
  78. +9 −7 entries/element-selector.xml
  79. +8 −5 entries/empty-selector.xml
  80. +16 −14 entries/empty.xml
  81. +9 −4 entries/enabled-selector.xml
  82. +20 −17 entries/end.xml
  83. +16 −15 entries/eq-selector.xml
  84. +25 −23 entries/eq.xml
  85. +10 −8 entries/error.xml
  86. +13 −9 entries/even-selector.xml
  87. +14 −10 entries/event.currentTarget.xml
  88. +8 −7 entries/event.data.xml
  89. +13 −11 entries/event.delegateTarget.xml
  90. +4 −3 entries/event.isDefaultPrevented.xml
  91. +12 −9 entries/event.isImmediatePropagationStopped.xml
  92. +9 −6 entries/event.isPropagationStopped.xml
  93. +9 −6 entries/event.namespace.xml
  94. +8 −8 entries/event.pageX.xml
  95. +5 −4 entries/event.pageY.xml
  96. +8 −5 entries/event.preventDefault.xml
  97. +8 −5 entries/event.relatedTarget.xml
  98. +9 −7 entries/event.result.xml
  99. +15 −15 entries/event.stopImmediatePropagation.xml
  100. +11 −9 entries/event.stopPropagation.xml
  101. +8 −5 entries/event.target.xml
  102. +14 −12 entries/event.timeStamp.xml
  103. +4 −3 entries/event.type.xml
  104. +8 −5 entries/event.which.xml
  105. +10 −12 entries/fadeIn.xml
  106. +34 −36 entries/fadeOut.xml
  107. +39 −40 entries/fadeTo.xml
  108. +15 −17 entries/fadeToggle.xml
  109. +14 −12 entries/file-selector.xml
  110. +26 −26 entries/filter.xml
  111. +44 −45 entries/find.xml
  112. +13 −8 entries/first-child-selector.xml
  113. +11 −7 entries/first-selector.xml
  114. +10 −9 entries/first.xml
  115. +17 −12 entries/focus-selector.xml
  116. +29 −26 entries/focus.xml
  117. +16 −13 entries/focusin.xml
  118. +13 −10 entries/focusout.xml
  119. +27 −19 entries/get.xml
  120. +14 −11 entries/gt-selector.xml
  121. +13 −10 entries/has-attribute-selector.xml
  122. +25 −23 entries/has-selector.xml
  123. +8 −9 entries/has.xml
  124. +10 −9 entries/hasClass.xml
  125. +10 −10 entries/header-selector.xml
  126. +57 −53 entries/height.xml
  127. +11 −10 entries/hidden-selector.xml
  128. +38 −42 entries/hide.xml
  129. +60 −63 entries/hover.xml
  130. +74 −77 entries/html.xml
  131. +15 −12 entries/id-selector.xml
  132. +12 −9 entries/image-selector.xml
  133. +61 −50 entries/index.xml
  134. +16 −14 entries/innerHeight.xml
  135. +13 −8 entries/innerWidth.xml
  136. +17 −14 entries/input-selector.xml
  137. +13 −11 entries/insertAfter.xml
  138. +24 −21 entries/insertBefore.xml
  139. +50 −61 entries/is.xml
  140. +44 −75 entries/jQuery.Callbacks.xml
  141. +198 −225 entries/jQuery.ajax.xml
  142. +21 −33 entries/jQuery.ajaxPrefilter.xml
  143. +13 −10 entries/jQuery.ajaxSetup.xml
  144. +138 −158 entries/jQuery.ajaxTransport.xml
  145. +17 −14 entries/jQuery.boxModel.xml
  146. +81 −79 entries/jQuery.browser.xml
  147. +11 −8 entries/jQuery.contains.xml
  148. +47 −34 entries/jQuery.cssHooks.xml
  149. +73 −72 entries/jQuery.data.xml
  150. +15 −13 entries/jQuery.dequeue.xml
  151. +22 −20 entries/jQuery.each.xml
  152. +5 −2 entries/jQuery.error.xml
  153. +25 −31 entries/jQuery.extend.xml
  154. +10 −9 entries/jQuery.fx.interval.xml
  155. +13 −12 entries/jQuery.fx.off.xml
  156. +30 −32 entries/jQuery.get.xml
  157. +33 −39 entries/jQuery.getJSON.xml
  158. +42 −42 entries/jQuery.getScript.xml
  159. +8 −7 entries/jQuery.globalEval.xml
  160. +23 −25 entries/jQuery.grep.xml
  161. +7 −5 entries/jQuery.hasData.xml
  162. +8 −7 entries/jQuery.holdReady.xml
  163. +11 −10 entries/jQuery.inArray.xml
  164. +6 −3 entries/jQuery.isArray.xml
  165. +2 −1 entries/jQuery.isEmptyObject.xml
  166. +15 −12 entries/jQuery.isFunction.xml
  167. +9 −9 entries/jQuery.isNumeric.xml
  168. +11 −8 entries/jQuery.isPlainObject.xml
  169. +5 −2 entries/jQuery.isWindow.xml
  170. +9 −8 entries/jQuery.isXMLDoc.xml
  171. +14 −14 entries/jQuery.makeArray.xml
  172. +58 −59 entries/jQuery.map.xml
  173. +19 −19 entries/jQuery.merge.xml
  174. +32 −30 entries/jQuery.noConflict.xml
  175. +8 −5 entries/jQuery.noop.xml
  176. +4 −3 entries/jQuery.now.xml
  177. +44 −40 entries/jQuery.param.xml
  178. +5 −4 entries/jQuery.parseJSON.xml
  179. +10 −11 entries/jQuery.parseXML.xml
  180. +46 −48 entries/jQuery.post.xml
  181. +14 −13 entries/jQuery.proxy.xml
  182. +75 −73 entries/jQuery.queue.xml
  183. +11 −9 entries/jQuery.removeData.xml
  184. +21 −17 entries/jQuery.sub.xml
  185. +33 −24 entries/jQuery.support.xml
  186. +4 −3 entries/jQuery.trim.xml
  187. +6 −18 entries/jQuery.type.xml
  188. +10 −10 entries/jQuery.unique.xml
  189. +15 −12 entries/jQuery.when.xml
  190. +186 −200 entries/jQuery.xml
  191. +10 −6 entries/jquery-2.xml
  192. +10 −7 entries/keydown.xml
  193. +15 −15 entries/keypress.xml
  194. +23 −21 entries/keyup.xml
  195. +16 −11 entries/last-child-selector.xml
  196. +16 −13 entries/last-selector.xml
  197. +10 −9 entries/last.xml
  198. +16 −11 entries/length.xml
  199. +36 −46 entries/live.xml
  200. +23 −20 entries/load-event.xml
  201. +34 −37 entries/load.xml
  202. +15 −14 entries/lt-selector.xml
  203. +24 −25 entries/map.xml
  204. +30 −27 entries/mousedown.xml
  205. +12 −11 entries/mouseenter.xml
  206. +14 −14 entries/mouseleave.xml
  207. +25 −23 entries/mousemove.xml
  208. +24 −24 entries/mouseout.xml
  209. +15 −17 entries/mouseover.xml
  210. +17 −12 entries/mouseup.xml
  211. +22 −19 entries/multiple-attribute-selector.xml
  212. +19 −16 entries/multiple-selector.xml
  213. +6 −5 entries/next-adjacent-Selector.xml
  214. +13 −10 entries/next-siblings-selector.xml
  215. +15 −14 entries/next.xml
  216. +20 −22 entries/nextAll.xml
  217. +17 −16 entries/nextUntil.xml
  218. +11 −6 entries/not-selector.xml
  219. +24 −23 entries/not.xml
  220. +18 −18 entries/nth-child-selector.xml
  221. +18 −14 entries/odd-selector.xml
  222. +24 −27 entries/off.xml
  223. +63 −60 entries/offset.xml
  224. +11 −11 entries/offsetParent.xml
  225. +53 −87 entries/on.xml
  226. +15 −16 entries/one.xml
  227. +16 −11 entries/only-child-selector.xml
  228. +16 −13 entries/outerHeight.xml
  229. +16 −13 entries/outerWidth.xml
  230. +10 −8 entries/parent-selector.xml
  231. +13 −12 entries/parent.xml
  232. +17 −16 entries/parents.xml
  233. +11 −12 entries/parentsUntil.xml
  234. +14 −13 entries/password-selector.xml
  235. +16 −13 entries/position.xml
  236. +30 −29 entries/prepend.xml
  237. +23 −22 entries/prependTo.xml
  238. +12 −11 entries/prev.xml
  239. +13 −12 entries/prevAll.xml
  240. +17 −18 entries/prevUntil.xml
  241. +21 −18 entries/promise.xml
  242. +130 −116 entries/prop.xml
  243. +10 −9 entries/pushStack.xml
  244. +74 −71 entries/queue.xml
  245. +18 −15 entries/radio-selector.xml
  246. +16 −13 entries/ready.xml
  247. +19 −17 entries/remove.xml
  248. +12 −11 entries/removeAttr.xml
  249. +25 −25 entries/removeClass.xml
  250. +12 −12 entries/removeData.xml
  251. +12 −13 entries/removeProp.xml
  252. +10 −9 entries/replaceAll.xml
  253. +33 −32 entries/replaceWith.xml
  254. +17 −14 entries/reset-selector.xml
  255. +10 −11 entries/resize.xml
  256. +16 −15 entries/scroll.xml
  257. +47 −45 entries/scrollLeft.xml
  258. +44 −40 entries/scrollTop.xml
  259. +20 −18 entries/select.xml
  260. +17 −14 entries/selected-selector.xml
  261. +37 −35 entries/selector.xml
  262. +12 −13 entries/serialize.xml
  263. +16 −15 entries/serializeArray.xml
  264. +39 −42 entries/show.xml
  265. +15 −14 entries/siblings.xml
  266. +16 −11 entries/size.xml
  267. +31 −32 entries/slice.xml
  268. +17 −18 entries/slideDown.xml
  269. +20 −22 entries/slideToggle.xml
  270. +31 −33 entries/slideUp.xml
  271. +17 −19 entries/stop.xml
  272. +17 −14 entries/submit-selector.xml
  273. +24 −25 entries/submit.xml
  274. +16 −15 entries/text-selector.xml
  275. +66 −65 entries/text.xml
  276. +13 −10 entries/toArray.xml
  277. +37 −33 entries/toggle-event.xml
  278. +37 −40 entries/toggle.xml
  279. +26 −29 entries/toggleClass.xml
  280. +33 −32 entries/trigger.xml
  281. +13 −12 entries/triggerHandler.xml
  282. +26 −23 entries/unbind.xml
  283. +28 −27 entries/undelegate.xml
  284. +12 −10 entries/unload.xml
  285. +14 −11 entries/unwrap.xml
  286. +78 −82 entries/val.xml
  287. +14 −13 entries/visible-selector.xml
  288. +58 −58 entries/width.xml
  289. +29 −28 entries/wrap.xml
  290. +25 −24 entries/wrapAll.xml
  291. +32 −31 entries/wrapInner.xml
  292. +37 −0 grunt.js
View
@@ -1,4 +1,5 @@
-<entry type='method' name="add" return="jQuery">
+<?xml version="1.0"?>
+<entry type="method" name="add" return="jQuery">
<title>.add()</title>
<signature>
<added>1.0</added>
@@ -34,51 +35,64 @@
</argument>
</signature>
<desc>Add elements to the set of matched elements.</desc>
- <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>
-<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>
-<pre><code>
+ <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>
+ <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>
+ <pre>
+ <code>
$("p").add("div").addClass("widget");
var pdiv = $("p").add("div");
-</code></pre>
-<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>
-<pre><code>
+</code>
+ </pre>
+ <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>
+ <pre>
+ <code>
var pdiv = $("p");
pdiv.add("div"); // WRONG, pdiv will not change
-</code></pre>
-<p>Consider a page with a simple list and a paragraph following it:</p>
-<pre><code>&lt;ul&gt;
+</code>
+ </pre>
+ <p>Consider a page with a simple list and a paragraph following it:</p>
+ <pre>
+ <code>&lt;ul&gt;
&lt;li&gt;list item 1&lt;/li&gt;
&lt;li&gt;list item 2&lt;/li&gt;
&lt;li&gt;list item 3&lt;/li&gt;
&lt;/ul&gt;
-&lt;p&gt;a paragraph&lt;/p&gt;</code></pre>
-<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>
-<pre><code>$('li').add('p').css('background-color', 'red');</code></pre>
-<p>Or:</p>
-<pre><code>$('li').add(document.getElementsByTagName('p')[0])
- .css('background-color', 'red');</code></pre>
-<p>The result of this call is a red background behind all four elements.
+&lt;p&gt;a paragraph&lt;/p&gt;</code>
+ </pre>
+ <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>
+ <pre>
+ <code>$('li').add('p').css('background-color', 'red');</code>
+ </pre>
+ <p>Or:</p>
+ <pre>
+ <code>$('li').add(document.getElementsByTagName('p')[0])
+ .css('background-color', 'red');</code>
+ </pre>
+ <p>The result of this call is a red background behind all four elements.
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>
-<pre><code>$('li').add('&lt;p id="new"&gt;new paragraph&lt;/p&gt;')
- .css('background-color', 'red');</code></pre>
-<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>
-<p>As of jQuery 1.4 the results from .add() will always be returned in document order (rather than a simple concatenation).</p>
-<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>
-</longdesc>
-<example>
- <desc>Finds all divs and makes a border. Then adds all paragraphs to the jQuery object to set their backgrounds yellow.</desc>
- <code><![CDATA[
+ <pre>
+ <code>$('li').add('&lt;p id="new"&gt;new paragraph&lt;/p&gt;')
+ .css('background-color', 'red');</code>
+ </pre>
+ <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>
+ <p>As of jQuery 1.4 the results from .add() will always be returned in document order (rather than a simple concatenation).</p>
+ <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>
+ </longdesc>
+ <example>
+ <desc>Finds all divs and makes a border. Then adds all paragraphs to the jQuery object to set their backgrounds yellow.</desc>
+ <code><![CDATA[
$("div").css("border", "2px solid red")
.add("p")
.css("background", "yellow");
]]></code>
- <css><![CDATA[
+ <css><![CDATA[
div { width:60px; height:60px; margin:10px; float:left; }
p { clear:left; font-weight:bold; font-size:16px;
color:blue; margin:0 10px; padding:2px; }
]]></css>
-<html><![CDATA[<div></div>
+ <html><![CDATA[<div></div>
<div></div>
<div></div>
@@ -87,31 +101,31 @@ $("div").css("border", "2px solid red")
<div></div>
<p>Added this... (notice no border)</p>]]></html>
-</example>
-<example>
- <desc>Adds more elements, matched by the given expression, to the set of matched elements.</desc>
- <code><![CDATA[$("p").add("span").css("background", "yellow");]]></code>
- <html><![CDATA[<p>Hello</p><span>Hello Again</span>]]></html>
-</example>
-<example>
- <desc>Adds more elements, created on the fly, to the set of matched elements.</desc>
- <code><![CDATA[$("p").clone().add("<span>Again</span>").appendTo(document.body);]]></code>
- <html><![CDATA[<p>Hello</p>]]></html>
-</example>
-<example>
- <desc>Adds one or more Elements to the set of matched elements.</desc>
- <code><![CDATA[$("p").add(document.getElementById("a")).css("background", "yellow");]]></code>
- <html><![CDATA[<p>Hello</p><span id="a">Hello Again</span>]]></html>
-</example>
-<example>
- <desc>Demonstrates how to add (or push) elements to an existing collection</desc>
- <code><![CDATA[var collection = $("p");
+ </example>
+ <example>
+ <desc>Adds more elements, matched by the given expression, to the set of matched elements.</desc>
+ <code><![CDATA[$("p").add("span").css("background", "yellow");]]></code>
+ <html><![CDATA[<p>Hello</p><span>Hello Again</span>]]></html>
+ </example>
+ <example>
+ <desc>Adds more elements, created on the fly, to the set of matched elements.</desc>
+ <code><![CDATA[$("p").clone().add("<span>Again</span>").appendTo(document.body);]]></code>
+ <html><![CDATA[<p>Hello</p>]]></html>
+ </example>
+ <example>
+ <desc>Adds one or more Elements to the set of matched elements.</desc>
+ <code><![CDATA[$("p").add(document.getElementById("a")).css("background", "yellow");]]></code>
+ <html><![CDATA[<p>Hello</p><span id="a">Hello Again</span>]]></html>
+ </example>
+ <example>
+ <desc>Demonstrates how to add (or push) elements to an existing collection</desc>
+ <code><![CDATA[var collection = $("p");
// capture the new collection
collection = collection.add(document.getElementById("a"));
collection.css("background", "yellow");]]></code>
- <html><![CDATA[<p>Hello</p><span id="a">Hello Again</span>]]></html>
-</example>
-<category slug="traversing/miscellaneous-traversal"/>
-<category slug="version/1.0"/>
-<category slug="version/1.4"/>
+ <html><![CDATA[<p>Hello</p><span id="a">Hello Again</span>]]></html>
+ </example>
+ <category slug="traversing/miscellaneous-traversal"/>
+ <category slug="version/1.0"/>
+ <category slug="version/1.4"/>
</entry>
View
@@ -1,4 +1,5 @@
-<entry type='method' name="addClass" return="jQuery">
+<?xml version="1.0"?>
+<entry type="method" name="addClass" return="jQuery">
<title>.addClass()</title>
<signature>
<added>1.0</added>
@@ -13,52 +14,52 @@
</argument>
</signature>
<desc>Adds the specified class(es) to each of the set of matched elements.</desc>
- <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>
- <p>More than one class may be added at a time, separated by a space, to the set of matched elements, like so:</p>
- <pre>$("p").addClass("myClass yourClass");</pre>
- <p>This method is often used with <code>.removeClass()</code> to switch elements' classes from one to another, like so:</p>
- <pre>$("p").removeClass("myClass noClass").addClass("yourClass");</pre>
- <p>Here, the <code>myClass</code> and <code>noClass</code> classes are removed from all paragraphs, while <code>yourClass</code> is added.</p>
-<p>As of jQuery 1.4, the <code>.addClass()</code> method's argument can receive a function.</p>
-<pre>$("ul li:last").addClass(function(index) {
+ <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>
+ <p>More than one class may be added at a time, separated by a space, to the set of matched elements, like so:</p>
+ <pre>$("p").addClass("myClass yourClass");</pre>
+ <p>This method is often used with <code>.removeClass()</code> to switch elements' classes from one to another, like so:</p>
+ <pre>$("p").removeClass("myClass noClass").addClass("yourClass");</pre>
+ <p>Here, the <code>myClass</code> and <code>noClass</code> classes are removed from all paragraphs, while <code>yourClass</code> is added.</p>
+ <p>As of jQuery 1.4, the <code>.addClass()</code> method's argument can receive a function.</p>
+ <pre>$("ul li:last").addClass(function(index) {
return "item-" + index;
});</pre>
-<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>
-
-</longdesc>
- <example>
- <desc>Adds the class "selected" to the matched elements.</desc>
- <code><![CDATA[
+ <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>
+ </longdesc>
+ <example>
+ <desc>Adds the class "selected" to the matched elements.</desc>
+ <code><![CDATA[
$("p:last").addClass("selected");
]]></code>
- <css><![CDATA[
+ <css><![CDATA[
p { margin: 8px; font-size:16px; }
.selected { color:blue; }
.highlight { background:yellow; }
]]></css>
- <html><![CDATA[
+ <html><![CDATA[
<p>Hello</p>
<p>and</p>
<p>Goodbye</p>
]]></html>
-</example>
-<example>
- <desc>Adds the classes "selected" and "highlight" to the matched elements.</desc>
- <code><![CDATA[
+ </example>
+ <example>
+ <desc>Adds the classes "selected" and "highlight" to the matched elements.</desc>
+ <code><![CDATA[
$("p:last").addClass("selected highlight");
]]></code>
- <css><![CDATA[
+ <css><![CDATA[
p { margin: 8px; font-size:16px; }
.selected { color:red; }
.highlight { background:yellow; }
]]></css>
- <html><![CDATA[<p>Hello</p>
+ <html><![CDATA[<p>Hello</p>
<p>and</p>
<p>Goodbye</p>]]></html>
- </example>
- <example>
- <desc>Pass in a function to <code>.addClass()</code> to add the "green" class to a div that already has a "red" class.</desc>
- <code><![CDATA[
+ </example>
+ <example>
+ <desc>Pass in a function to <code>.addClass()</code> to add the "green" class to a div that already has a "red" class.</desc>
+ <code><![CDATA[
$("div").addClass(function(index, currentClass) {
var addedClass;
@@ -70,23 +71,22 @@
return addedClass;
});
]]></code>
-
- <css><![CDATA[
+ <css><![CDATA[
div { background: white; }
.red { background: red; }
.red.green { background: green; }
]]></css>
- <html><![CDATA[
+ <html><![CDATA[
<div>This div should be white</div>
<div class="red">This div will be green because it now has the "green" and "red" classes.
It would be red if the addClass function failed.</div>
<div>This div should be white</div>
<p>There are zero green divs</p>
]]></html>
-</example>
-<category slug="attributes"/>
-<category slug="manipulation/class-attribute"/>
-<category slug="css"/>
-<category slug="version/1.0"/>
-<category slug="version/1.4"/>
+ </example>
+ <category slug="attributes"/>
+ <category slug="manipulation/class-attribute"/>
+ <category slug="css"/>
+ <category slug="version/1.0"/>
+ <category slug="version/1.4"/>
</entry>
View
@@ -1,4 +1,5 @@
-<entry type='method' name="after" return="jQuery">
+<?xml version="1.0"?>
+<entry type="method" name="after" return="jQuery">
<title>.after()</title>
<signature>
<added>1.0</added>
@@ -16,29 +17,24 @@
</argument>
</signature>
<desc>Insert content, specified by the parameter, after each element in the set of matched elements.</desc>
- <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>
-
+ <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&#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>
<p>Using the following HTML:</p>
<pre>&lt;div class="container"&gt;
&lt;h2&gt;Greetings&lt;/h2&gt;
&lt;div class="inner"&gt;Hello&lt;/div&gt;
&lt;div class="inner"&gt;Goodbye&lt;/div&gt;
&lt;/div&gt;</pre>
-
<p>Content can be created and then inserted after several elements at once:</p>
-
<pre>$('.inner').after('&lt;p&gt;Test&lt;/p&gt;');</pre>
-
<p>Each inner <code>&lt;div&gt;</code> element gets this new content:</p>
-
<pre>&lt;div class="container"&gt;
&lt;h2&gt;Greetings&lt;/h2&gt;
&lt;div class="inner"&gt;Hello&lt;/div&gt;
&lt;p&gt;Test&lt;/p&gt;
&lt;div class="inner"&gt;Goodbye&lt;/div&gt;
&lt;p&gt;Test&lt;/p&gt;
&lt;/div&gt;</pre>
-
<p>An element in the DOM can also be selected and inserted after another element:</p>
<pre>$('.container').after($('h2'));</pre>
<p>If an element selected this way is inserted elsewhere, it will be moved rather than cloned:</p>
@@ -77,26 +73,26 @@
$('p').first().after($newdiv1, [newdiv2, existingdiv1]);
</pre>
<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>
-</longdesc>
+ </longdesc>
<example>
- <desc>Inserts some HTML after all paragraphs.</desc>
- <code><![CDATA[$("p").after("<b>Hello</b>");]]></code>
- <css><![CDATA[p { background:yellow; }]]></css>
- <html><![CDATA[<p>I would like to say: </p>]]></html>
+ <desc>Inserts some HTML after all paragraphs.</desc>
+ <code><![CDATA[$("p").after("<b>Hello</b>");]]></code>
+ <css><![CDATA[p { background:yellow; }]]></css>
+ <html><![CDATA[<p>I would like to say: </p>]]></html>
</example>
<example>
- <desc>Inserts a DOM element after all paragraphs.</desc>
- <code><![CDATA[$("p").after( document.createTextNode("Hello") );]]></code>
- <css><![CDATA[p { background:yellow; }]]></css>
- <html><![CDATA[<p>I would like to say: </p>]]></html>
+ <desc>Inserts a DOM element after all paragraphs.</desc>
+ <code><![CDATA[$("p").after( document.createTextNode("Hello") );]]></code>
+ <css><![CDATA[p { background:yellow; }]]></css>
+ <html><![CDATA[<p>I would like to say: </p>]]></html>
</example>
<example>
- <desc>Inserts a jQuery object (similar to an Array of DOM Elements) after all paragraphs.</desc>
- <code><![CDATA[$("p").after( $("b") );]]></code>
- <css><![CDATA[p { background:yellow; }]]></css>
- <html><![CDATA[<b>Hello</b><p>I would like to say: </p>]]></html>
+ <desc>Inserts a jQuery object (similar to an Array of DOM Elements) after all paragraphs.</desc>
+ <code><![CDATA[$("p").after( $("b") );]]></code>
+ <css><![CDATA[p { background:yellow; }]]></css>
+ <html><![CDATA[<b>Hello</b><p>I would like to say: </p>]]></html>
</example>
-<category slug="manipulation/dom-insertion-outside"/>
-<category slug="version/1.0"/>
-<category slug="version/1.4"/>
+ <category slug="manipulation/dom-insertion-outside"/>
+ <category slug="version/1.0"/>
+ <category slug="version/1.4"/>
</entry>
Oops, something went wrong.

0 comments on commit 96f3fec

Please sign in to comment.