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);
}
});