فهرست منبع

Listing 5.11: explicit iteration with each().

Frederic G. MARAND 8 سال پیش
والد
کامیت
399b0c356b
1فایلهای تغییر یافته به همراه4 افزوده شده و 6 حذف شده
  1. 4 6
      Chapter 5/05.js

+ 4 - 6
Chapter 5/05.js

@@ -18,10 +18,8 @@ $(document).ready(function () {
   // insertBefore <elem> prependTo <children /> appendTo </elem> insertAfter
 
   // Create footnotes.
-  // This works just as well, in spite of what the book says.
-  // $('span.footnote').insertAfter('div.chapter');
-  $('span.footnote')
-    .insertBefore('#footer')
-    .wrapAll('<ol id="notes"></ol>')
-    .wrap('<li></li>');
+  var $notes = $('<ol id="notes"></ol>').insertBefore('#footer');
+  $('span.footnote').each (function (index) {
+    $(this).appendTo($notes).wrap('<li></li>');
+  });
 });