document.addEventListener('DOMContentLoaded', function () {
const buttons = document.querySelectorAll('.scrolldownbutton'); // Select all buttons with class "scrolldownbutton"
buttons.forEach(button => {
button.addEventListener('click', function (e) {
const targetId = this.getAttribute('href').substring(1); // Get the target ID from href (e.g., "#pocetak")
const targetElement = document.getElementById(targetId); // Find the section with the target ID
if (targetElement) {
e.preventDefault(); // Prevent the default anchor link behavior
const headerHeight = document.querySelector('header').offsetHeight; // Get sticky header height
const elementPosition = targetElement.offsetTop;
// Scroll to the target section with an offset for the sticky header
window.scrollTo({
top: elementPosition - headerHeight,
behavior: 'smooth'
});
}
});
});
});