function slideUp(element, duration = 400) { element.style.transitionProperty = 'height, margin, padding'; element.style.transitionDuration = duration + 'ms'; element.style.boxSizing = 'border-box'; element.style.height = element.offsetHeight + 'px'; element.offsetHeight; element.style.overflow = 'hidden'; element.style.height = 0; element.style.paddingTop = 0; element.style.paddingBottom = 0; element.style.marginTop = 0; element.style.marginBottom = 0; window.setTimeout(() => { element.style.display = 'none'; element.style.removeProperty('height'); element.style.removeProperty('padding-top'); element.style.removeProperty('padding-bottom'); element.style.removeProperty('margin-top'); element.style.removeProperty('margin-bottom'); element.style.removeProperty('overflow'); element.style.removeProperty('transition-duration'); element.style.removeProperty('transition-property'); }, duration); } function slideDown(element, duration = 400) { element.style.removeProperty('display'); let display = window.getComputedStyle(element).display; if (display === 'none') display = 'block'; element.style.display = display; let height = element.offsetHeight; element.style.overflow = 'hidden'; element.style.height = 0; element.style.paddingTop = 0; element.style.paddingBottom = 0; element.style.marginTop = 0; element.style.marginBottom = 0; element.offsetHeight; element.style.transitionProperty = "height, margin, padding"; element.style.transitionDuration = duration + 'ms'; element.style.height = height + 'px'; element.style.removeProperty('padding-top'); element.style.removeProperty('padding-bottom'); element.style.removeProperty('margin-top'); element.style.removeProperty('margin-bottom'); window.setTimeout(() => { element.style.removeProperty('height'); element.style.removeProperty('overflow'); element.style.removeProperty('transition-duration'); element.style.removeProperty('transition-property'); }, duration); } var qaElements = document.querySelectorAll('.js-qaBtn'); qaElements.forEach(function (elem) { elem.addEventListener('click', function () { if (elem.closest('.list__item').classList.contains('is-active')) { elem.closest('.list__item').classList.remove("is-active"); var qaItem = this.nextElementSibling; if (qaItem) slideUp(qaItem); // slideUp関数を呼び出し } else { elem.closest('.list__item').classList.add("is-active"); var qaItem = this.nextElementSibling; if (qaItem) slideDown(qaItem); // slideDown関数を呼び出し } }); }); // document.addEventListener('DOMContentLoaded', function () { // const mvVideo = document.getElementById('js-mvVideo') // const playBtn = document.getElementById('js-playBtn'); // console.log(mvVideo); // playBtn.addEventListener('click', function () { // playBtn.classList.add("is-disable"); // mvVideo.play(); // }); // });