feat(services-cards): add accordion feature to section
This commit is contained in:
17
src/scripts/services.js
Normal file
17
src/scripts/services.js
Normal file
@@ -0,0 +1,17 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const accordionHeaders = document.querySelectorAll('.accordion-header');
|
||||
|
||||
accordionHeaders.forEach(header => {
|
||||
header.addEventListener('click', function() {
|
||||
const content = this.nextElementSibling;
|
||||
|
||||
// Check if maxHeight has a value. If it does, the accordion is open.
|
||||
if (content.style.maxHeight) {
|
||||
content.style.maxHeight = null; // Close the accordion
|
||||
} else {
|
||||
// The accordion is closed, open it by setting max-height to its scroll height
|
||||
content.style.maxHeight = content.scrollHeight + 'px';
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user