Last active
February 2, 2016 11:57
-
-
Save cmaas/3c4674688da5bcb69416 to your computer and use it in GitHub Desktop.
Adds permalink anchor to all headlines in an article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add CSS: a.anchor { color: #ddd; text-decoration: none; } | |
* Requires jQuery for :header selector | |
*/ | |
$(function() { | |
$(":header[id]").each(function() { | |
var $this = $(this), | |
link = $this.html() + ' <a class="anchor" href="'+window.location.pathname+'#' + this.id + '" title="Permalink">#</a>'; | |
$this.html(link); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment