0
我有一個手風琴作爲標記,CSS和jQuery的相同給定。我無法建立外部錨鏈接(相同頁面和其他頁面)來觸發打開特定面板。手風琴來自模板。從同一頁面和外部頁面的錨點鏈接打開一個手風琴面板
HTML
<!-- Accordions -->
<h1 class="h-margin">Accordions</h1>
<div class="accordion-trigger">Categories</div>
<div class="accordion-container" data-panel="0">
Pellentesque habitant
</div>
<div class="accordion-trigger">Categories</div>
<div class="accordion-container" data-panel="1">
Pellentesque habitant morbi
</div>
<div class="accordion-trigger">Categories</div>
<div class="accordion-container" data-panel="2">
Pellentesque habitant morbi tris
</div>
<!-- ENDS Accordions -->
<a href="#">Open Section 1</a>
<a href="#">Open Section 2</a>
<a href="#">Open Section 3</a>
的JavaScript
// Accordion box
$('.accordion-container').hide();
$('.accordion-trigger:first').addClass('active').next().show();
$('.accordion-trigger').click(function(){
if($(this).next().is(':hidden')) {
$('.accordion-trigger').removeClass('active').next().slideUp();
$(this).toggleClass('active').next().slideDown();
}
return false;
});