Skip to content

Instantly share code, notes, and snippets.

@emayk
Created March 21, 2012 11:11
Show Gist options
  • Save emayk/2146259 to your computer and use it in GitHub Desktop.
Save emayk/2146259 to your computer and use it in GitHub Desktop.
jquery : div replace link
$(document).ready(function() {
$('div.chapter a[@href*=wikipedia]').each(function(index) {
var $thisLink = $(this);
$thisLink.attr({
'rel': 'external',
'id': 'wikilink-' + index,
'title': 'learn more about ' + $thisLink.text() + ' at Wikipedia'
}); });
});
$('<a href="#top">back to top</a>').insertAfter('div.chapter p');
$('div.chapter p').after('<a href="#top">back to top</a>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment