Here is a tabs code when tabs don't deactived when one is active. I try to use it for another page and add deactivation for tabs when one is active, but get console error $(...).parent(...).siblings(...).hasClass(...).each is not a function. I rarely work with jquery, please tell me how to do it right way.
var acc = $('.questions_item_title');
var accAnother = $('.page-another .questions_item_title');
for (var i = 0; i < acc.length; i ) {
acc[i].addEventListener("click", function() {
var panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = null;
$(this).parent('.questions_item').removeClass('active');
} else {
panel.style.maxHeight = panel.scrollHeight "px";
$(this).parent('.questions_item').addClass('active')
for (var j = 0; j < accAnother.length; j ) {
$(this).parent('.questions_item').siblings().hasClass('active').removeClass('active');
};
}
});
}
accAnother[0].parentElement.classList.add("active");
accAnother[0].nextElementSibling.style.maxHeight = accCredLine[0].nextElementSibling.scrollHeight "px";
CodePudding user response:
