$(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.
$('div.chapter p').slice(4).after($('back to top'));
$('').prependTo('body');
// insertBefore
You were here
')).next('p'); setTimeout(function () { $youWereHere.remove(); }, 3000) }); $('#f-author').click(function () { var $this = $(this); var $b = $('b', this); if ($b.length) { $this.text($b.text()); } else { $this.wrapInner(''); } }); $('p').each(function () { var $this = $(this); var sClass = $this.attr('class') ? $this.attr('class') : ''; var aClass = sClass.split(' '); // In a more general case, we would also need to : // - remove multiple spacers // - order and deduplicate existing classes. aClass.push('inhabitants'); sClass = aClass.join(' ').trim(); $this.attr('class', sClass); }); });