(function ($) { $(function () { var faq_accordion = $('#faq_accordion'); if (faq_accordion.length) { faq_accordion.accordion({ active: 0, heightStyle: "content", collapsible: true }); var faq_container = $('.faq'), faq_link = $('a[href="#faq"]'), body = $('body'); faq_link.on('click.anfaq', function (ev) { ev.preventDefault(); faq_container.toggleClass('faq--open'); body.toggleClass('body--faq--open'); }); $('.faq__close').on('click.anfaq', function (ev) { ev.preventDefault(); faq_link.filter(':first').trigger('click.anfaq'); }); faq_container.on('click.anfaq', function (ev) { ev.preventDefault(); if ($(ev.target).hasClass('faq')) { faq_link.filter(':first').trigger('click.anfaq'); } }); } }); })(jQuery);