5
How do I make a jQuery that recognizes if aria-selected="false"
and if true change the background of the div "arrow-btn-sub" to another image (arrow img). This is part of an acordion and I want to change the image of the arrow when the part is open (<div id="outraDiv">
), area Selected appears inside H3.
<h3>
<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>
I’ve done something like this so far, but I haven’t been able to make it work
<script>
if($("#aria-selected").val() == true){
$(".seta-btn-sub").css("background-image","url(images/seta-blue.png);");
}
else if($("#aria-selected").val() == false){
$(".seta-btn-sub").css("background-image","url(images/seta-padrao-azul.png);");
}
</script>
As far as I understand the
aria-selected
should be set by a specific implementation, it is not something automatic from HTML or browser. It has some specific plugin that you are using?– utluiz
Yes, I am using "acoordion" (http://jqueryui.com/accordion/) that inserts within H3 the condition (Aria-Selected="true") when I open the desired UL, what I want is to change the image of the arrow (background of the div arrow-btn-sub) that is to the side, to another arrow. Summarizing, i.e., when it is (Aria-Selected="true") change the background of the div "arrow-btn-sub" to another background-image. Thank you
– CRAJ
@CRAJ Remember that if you want to say more about your problem (like the code example you posted) you don’t need to create a new answer. You can edit your question and post the necessary information. Welcome to SOPT :)
– Gabe