diff --git a/public/index.html b/public/index.html index 3b79a8e..2ec7764 100644 --- a/public/index.html +++ b/public/index.html @@ -26,7 +26,7 @@
-

FPV drone opnames laten maken

+

FPV drone opnames laten maken

@@ -102,7 +102,7 @@
-

Wat is FPV?

+

Wat is FPV?

@@ -119,8 +119,9 @@

+
-

Over mij

+

Over mij

Afbeelding van mezelf terwijl ik een FPV drone bestuur. @@ -146,7 +147,7 @@
-

Werkwijze

+

Werkwijze

diff --git a/src/js/scripts.js b/src/js/scripts.js index e123656..c9fe264 100644 --- a/src/js/scripts.js +++ b/src/js/scripts.js @@ -28,17 +28,20 @@ document.addEventListener('DOMContentLoaded', () => /** * @type {NodeListOf} */ - const sections = document.querySelectorAll('.section'); + const sections = document.querySelectorAll('section'); sections.forEach(section => { - if (section.id) + const anchorTarget = section.querySelector('[id^="section-"]'); + const anchorHeader = section.querySelector('h1,h2'); + + if (anchorTarget && anchorHeader) { - const anchor = document.createElement('a'); - anchor.className = 'anchor-link'; - anchor.href = `#${section.id}`; - anchor.innerHTML = ' # '; - section.appendChild(anchor); + const anchorLink = document.createElement('a'); + anchorLink.className = 'anchor-link'; + anchorLink.href = `#${anchorTarget.id}`; + anchorLink.innerHTML = ' # '; + anchorHeader.appendChild(anchorLink); } });