$(document).ready(function () { AccordeonInitializer.init(); }); class AccordeonInitializer { public static init() { $(".accordeon_trigger").each((index, item) => { AccordeonInitializer.InitCustomAccordeon(item); }); } public static InitCustomAccordeon($accordeon: HTMLElement) { // Cache the number of options let $this = $($accordeon); $this.click(function () { const trigger = $(this); let content = trigger.siblings('.accordeon_content'); let time = 300; if (!content.hasClass('open')) { content.stop().slideDown(time).addClass('open'); trigger.addClass('active'); } else { content.stop().slideUp(time).removeClass('open'); trigger.removeClass('active'); } }); } }