I need a help with the following problem, I have the following HTML, which is part of an accordion
<div id="accordion2">
<h3 class="btn-sub-main"><a>Banho</a><div class="seta-btn-sub"></div></h3>
<div id="outraDiv">
<ul>
<li><a href="#">condicionadores</a><span></span></li>
<li><a href="#">sabonetes</a><span></span></li>
<li><a href="#">shampoos</a><span></span></li>
<li><a href="#">outros</a><span></span></li>
</ul>
</div>
<h3 class="btn-sub-main"><a>Higiene Infantil</a><div class="seta-btn-sub"></div></h3>
<div id="outraDiv">
<ul>
<li><a href="#">condicionadores</a><span></span></li>
<li><a href="#">sabonetes</a><span></span></li>
</ul>
</div>
<h3 class="btn-sub-main"><a>Alimentação</a><div class="seta-btn-sub"></div></h3>
<div id="outraDiv">
<ul>
<li><a href="#">condicionadores</a><span></span></li>
<li><a href="#">outros</a><span></span></li>
</ul>
</div>
</div>
I have the following Javascript code that changes the background of the DIV="arrow-btn-sub" (arrow image):
$(function() {
$("#accordion2").accordion({
icons: null,
beforeActivate: function( event, ui ) {
$("#" + ui.newHeader.attr("id")).children(".seta-btn-sub").toggleClass("active");
$("#" + ui.oldHeader.attr("id")).children(".seta-btn-sub").toggleClass("active");
},
create: function( event, ui ) {
$("#" + ui.header.attr("id")).children(".seta-btn-sub").toggleClass("active");
}
});
});
I have tried in many ways to do what I want based on this code, but I could not. I want the h3 that has the "btn-sub-main" class to change the background color when the aria-hidden ') field ==' true , or add a class and then insert the CSS characteristic I desire.
Below is another script that exists in this accordion that hides / shows me the div="otherDiv" , I tried to join it in several ways but could not.
controlaOutraDiv = function(selector){
$("#accordion2 h3", selector).bind('click',function(){
console.log($(this).next().attr('aria-hidden'));
if($(this).next().attr('aria-hidden')=='true'){
$("#outraDiv ul li").show();
}else if($(this).next().attr('aria-hidden')=='false'){
$("#outraDiv ul li").hide();
}
});
}
Accordion effect code:
$(function() {
$("#accordion2").accordion({
collapsible: true
});
controlaOutraDiv("#accordion2");
});