05.js 821 B

1234567891011121314151617181920212223242526
  1. $(document).ready(function () {
  2. 'use strict';
  3. // Use attr() to add an id, rel, and title.
  4. $('div.chapter a[href*="wikipedia"]').attr({
  5. rel: 'external',
  6. title: function () {
  7. return 'Learn more about ' + $(this).text() + ' at Wikipedia.';
  8. },
  9. id: function (index, oldValue) {
  10. return 'wikilink-' + index;
  11. }
  12. });
  13. // Add "back to top" links.
  14. $('<a href="#top">back to top</a>').insertAfter('div.chapter p');
  15. $('<a id="top"></a>').prependTo('body');
  16. // insertBefore <elem> prependTo <children /> appendTo </elem> insertAfter
  17. // Create footnotes.
  18. var $notes = $('<ol id="notes"></ol>').insertBefore('#footer');
  19. $('span.footnote').each (function (index) {
  20. $('<sup>' + (index + 1) + '</sup>').insertBefore(this);
  21. $(this).appendTo($notes).wrap('<li></li>');
  22. });
  23. });