I have a button inside accordion panel that shows additional content on click. How do I adjust the height of the its parent div to fit content? Below is the event listener of my button.
askbtn.addEventListener('click', () => {
document.querySelector(".ywqa-ask-question").style.display = "block";
askbtn.style.display = 'none';
const accAll = document.querySelectorAll('button.accordion.active');
let panel = accAll.nextElementSibling;
panel.style.maxHeight = panel.scrollHeight + "px";
})
I am getting an error "Uncaught TypeError: Cannot read properties of undefined (reading 'style')". Here's my sample page. https://staging.buellairhorns.com/product/buell-5-chime-rail-air-horn