12345678910111213141516171819202122232425262728293031323334353637 |
- $(document).ready(function () {
- 'use strict';
- // Use attr() to add an id, rel, and title.
- $('div.chapter a[href*="wikipedia"]').attr({
- rel: 'external',
- title: function () {
- return 'Learn more about ' + $(this).text() + ' at Wikipedia.';
- },
- id: function (index, oldValue) {
- return 'wikilink-' + index;
- }
- });
- // Add "back to top" links.
- $('<a href="#top">back to top</a>').insertAfter('div.chapter p');
- $('<a id="top"></a>').prependTo('body');
- // insertBefore <elem> prependTo <children /> appendTo </elem> insertAfter
- // Create footnotes.
- var $notes = $('<ol id="notes"></ol>').insertBefore('#footer');
- $('span.footnote').each (function (index) {
- $(this)
- .before([
- '<a href="#footnote-',
- index + 1,
- '" id="context-',
- index + 1,
- '" class="context">',
- '<sup>',
- index + 1,
- '</sup></a>'
- ].join(''))
- .appendTo($notes)
- .wrap('<li id="footnote-' + (index + 1) + '"></li>');
- });
- });
|