theread.me/js/heading-links.js

13 lines
315 B
JavaScript
Raw Permalink Normal View History

2015-07-31 05:51:07 +00:00
(function() {
var els = document.querySelectorAll('.post-content [id]');
var headings = Array.prototype.slice.call(els);
headings.forEach(function(head) {
var link = document.createElement('a');
link.className = 'heading-link';
link.href = '#' + head.id;
head.appendChild(link);
});
}());