2017-01-28 142 views
0

我有這個引導面板崩潰的JavaScript,在DIV中沒有ID,因爲在頁面中的其他面板出現問題。Bootstrap - 加載面板崩潰

這是我崩潰面板及其不會崩潰時加載頁面。

<div class="panel panel-primary"> 
     <div class="panel-heading"> 
      <h3 class="panel-title">Panel 1</h3> 
      <span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-up"></i></span> 
     </div> 
     <div class="panel-body"> 
      Panel content 
     </div> 
    </div> 

的Javascript:

$(document).on('click', '.panel-heading span.clickable', function(e){ 
    var $this = $(this); 
    if(!$this.hasClass('panel-collapsed')) { 
     $this.parents('.panel').find('.panel-body').slideUp(); 
     $this.addClass('panel-collapsed'); 
     $this.find('i').removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down'); 
    } else { 
     $this.parents('.panel').find('.panel-body').slideDown(); 
     $this.removeClass('panel-collapsed'); 
     $this.find('i').removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up'); 
    } 
}) 

和CSS:

.row{ 
    margin-top:40px; 
    padding: 0 10px; 
} 

.clickable{ 
    cursor: pointer; 
} 

.panel-heading span { 
    margin-top: -20px; 
    font-size: 15px; 
} 

當頁面加載如何加載合攏面板?

我希望解釋我的問題 感謝

+0

你'包括jQuery'?什麼是'控制檯錯誤'? – talkhabi

回答

0

只是使它默認處於摺疊狀態:

<div class="panel panel-primary"> 
    <div class="panel-heading"> 
     <h3 class="panel-title">Panel 1</h3> 
     <span class="pull-right clickable panel-collapsed"><i class="glyphicon glyphicon-chevron-down"></i></span> 
    </div> 
    <div class="panel-body"> 
     Panel content 
    </div> 
</div> 

CSS

.panel-body { 
    display: none; 
}