$('.accordion').each(function () { var $this = $(this); $this.on("click", function () { var el = $(this).data('target'); var panel = document.getElementById(el); panel.classList.add("active"); /* if (panel.style.maxHeight) { panel.style.maxHeight = null; } else { panel.style.maxHeight = panel.scrollHeight + "px"; }*/ }); });