feat: added faq
This commit is contained in:
21
assets/js/faq.js
Normal file
21
assets/js/faq.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const faqItems = document.querySelectorAll('.faq__item');
|
||||
|
||||
faqItems.forEach((faqItem) => {
|
||||
faqItem.addEventListener('click', (event) => {
|
||||
event.currentTarget.classList.toggle('active');
|
||||
const panel = event.currentTarget.querySelector('.faq__item-answer');
|
||||
const parentFaqItems = document.querySelectorAll('.faq__item');
|
||||
parentFaqItems.forEach((item) => {
|
||||
if (item !== event.currentTarget && item.classList.contains('active')) {
|
||||
item.classList.remove('active');
|
||||
const itemPanel = item.querySelector('.faq__item-answer');
|
||||
itemPanel.style.maxHeight = null;
|
||||
}
|
||||
});
|
||||
if (panel.style.maxHeight) {
|
||||
panel.style.maxHeight = null;
|
||||
} else {
|
||||
panel.style.maxHeight = panel.scrollHeight + 'px';
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
import './sliders.js';
|
||||
import './step-by-step.js';
|
||||
import './team.js';
|
||||
import './faq.js';
|
||||
|
||||
Reference in New Issue
Block a user