2016-05-18 4 views
1

Ich habe Probleme, den Bootstrap-Akkordeon-Dropdown-Link blau bleiben zu lassen, wenn er aktiv ist. Versuchte Dinge variieren, und keiner von ihnen hat funktioniert. Was mache ich falsch? Hier ist mein Code.Wie kann ich meinen Dropdown-Link blau bleiben lassen, wenn er aktiviert ist?

<div class="visible-sm visible-xs" id="accordion" role="tablist" aria-multiselectable="true"> 
     <div class="panel panel-default"> 
     <div class="panel-heading" role="tab" id="headingOne"> 
      <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne"> 
       <h4 class="panel-title"> 
       Advertise Jobs 
       </h4> 
     </a> 
     </div> 
     <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne"> 
      <h1>Reach the Right Candidates</h1> 
      <p>Attract and recruit candidates by location, industry, specific skills and/or occupation</p> 
     </div> 
     </div> 
     <div class="panel panel-default"> 
     <div class="panel-heading" role="tab" id="headingTwo"> 
      <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> 
       <h4 class="panel-title"> 
       Source Talent 
       </h4> 
      </a> 

     </div> 
     <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo"> 
      <h1>Reach the Right Candidates</h1> 
      <p>Attract and recruit candidates by location, industry, specific skills and/or occupation</p> 


     </div> 
     </div> 
     <div class="panel panel-2"> 
     <div class="panel-heading" role="tab" id="headingThree"> 
      <h4 class="panel-title"> 
      <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree"> 
       Recruit Socially 
      </a> 
      </h4> 
     </div> 
     <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree"> 
      Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. 
     </div> 
     </div> 

    </div> 

JSfiddle demo

Antwort

0

Sie benötigen eine benutzerdefinierte Klasse zum getoggelt Panel anzuhängen. Sie können das mit jQuery tun.

Zum einen fügen diese zu Ihrem JS:

jQuery('.panel-heading a').click(function() { 
    $('.panel-heading').removeClass('open-panel'); 
    $(this).parents('.panel-heading').addClass('open-panel'); 
}); 

Dies wird die Klasse open-panel auf das aktive Panel hinzuzufügen.

Zweitens fügen diese zu Ihrem CSS:

.open-panel h4 { 
    background-color: #00aff0; 
} 

Dies wird die bg-Farbe auf die geklickt Platten hinzuzufügen.

Drittens, ändern Sie Ihre HTML ein wenig, so dass die blaue BG wird da sein, wenn die Seite geladen wird. Dies kann durch Hinzufügen der Klasse open-panel zum Standardbereich erfolgen. diese

Wechsel:

<div class="panel-heading" role="tab"> 

Um dies:

<div class="panel-heading open-panel" role="tab"> 
+0

Auch Ihre Geige fehlte die 'jQuery' daher Datei, warum die Platten nicht funktionierten. –

+0

Arbeitete wie Wunder! Danke für Ihre Hilfe! –

+0

Ich bin froh, dass ich Sijie helfen konnte :) Upvote und markieren Sie dies als die richtige Antwort, wenn es Ihnen geholfen hat, Ihr Problem zu beheben. Prost!! –

Verwandte Themen