function writeFragLinks() { // This function makes everything of class 'fragLink' a hyperlink to itself // CSS will add the # symbol when hovered over // fragLink class applied to table captions, figcaptions and headings. // Hyperlink is to the parent - the table, the figure or the section const linkableElements = document.querySelectorAll('.fragLink'); for(const heading of linkableElements) { if (heading.parentNode.id) { heading.addEventListener("click", function (e){ location.hash = this.parentNode.id; // console.log(`Just clicked ${this.parentNode.id}`); }); } } }