Title here
Summary here
Add JavaScript code to enhance your site with interactivity and custom behavior.
JavaScript files live in assets/js/:
custom.js is for your custom JavaScriptEdit assets/js/custom.js to add your own scripts:
// Run code when the page loads
document.addEventListener("DOMContentLoaded", () => {
// Example: Toggle behavior for FAQ accordions
const details = document.querySelectorAll("details");
details.forEach((detail) => {
detail.addEventListener("toggle", () => {
if (detail.open) {
// Close other details when one opens
details.forEach((other) => {
if (other !== detail) other.open = false;
});
}
});
});
});Keep scripts focused and avoid blocking page load. Use DOMContentLoaded to ensure the DOM is ready before running code.
Learn about the DOM API and how to interact with HTML elements.
Reference for all available DOM events and event handling.
Process and bundle assets in your Hugo site.