Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to check if "true or false = expanded area?"

I have the following list in bootstrap

<i class="fa fa-plus rgh-i" data-toggle="collapse" data-target="#field-1"></i>
<i class="fa fa-plus rgh-i" data-toggle="collapse" data-target="#field-2"></i>
<i class="fa fa-plus rgh-i" data-toggle="collapse" data-target="#field-3"></i>

I use bootstrap to toggle a div.

Each element html i has a aria-expanded="true" when I want to show my div and aria-expanded="false" when I want to hide my div.

I want to check if there are already elements that aria-expanded="true"..and whether there next to hide the previous open.

$( "i" ).on( "click", function() {
        if(There are elements of that property aria-expanded="true")
       {
        hide previous item before you open the current one
       }else{
        //something
       }
});

I tried to make an example jsdfiddle but unfortunately we did ... I hope that you have understood what I want to do.

Basically ... I briefly before hiding the previous item to display the next and not be allowed to be open more than one element.

Thanks in advance!

like image 212
Marius Avatar asked Nov 09 '22 23:11

Marius


1 Answers

if(this.attr('aria-expanded') === "true"){
     // hide previous item before you open the current one
}
like image 122
NiallMitch14 Avatar answered Nov 14 '22 23:11

NiallMitch14