Attempting to create an accordion, but I can't figure out to check if the wrapper has the active class.
My jQuery:
$('.faq_wrap span.plus').on(touchClick, function (e) {
var topEl = $(this).closest('.faq_wrap');
if (topEl.hasClass('active')) {
topEl.removeClass('active');
topEl.find('.answer').slideUp('fast');
return false;
}
topEl.each(function (index, el) {
topEl.removeClass('active');
topEl.find('.answer').slideUp('fast');
});
topEl.find('.answer').slideDown('fast');
topEl.addClass('active');
console.log(topEl);
});
Here's the output from console.log:

I'm trying to check whether .faq_wrap.active already exists. If it does, slide the accordion up before sliding the new one down. As of right now, this check is ignored and I can open as many accordions at once as I want. Thoughts?
topEl.children, but checkingtopEl.hasClass. What happens if youconsole.log(topEl);?.activepiece, why not simply doif ($('.faq_wrap.active')) { ... rest of code? Wondering why you only check the closest.faq_wraptoo.