2013-07-18 102 views
0

我儘量讓圖標Chevron下跌,併爲我的手風琴與引導:圖標上下手風琴引導

我有這樣的:

http://jsfiddle.net/HwNYB/18/

我嘗試這個js但它沒有按」 t工作:

<script type="text/javascript"> 

$('.accordion').on('show hide', function (n) { 
    $(n.target).siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-chevron-up icon-chevron-down'); 
}); 
</script> 

當我點擊鏈接時,雪佛龍不起來。

img chevron

回答

4

你沒有一個.accordion元素?

$('.accordion-group').on('show hide', function (n) { 
    $(n.target).siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-chevron-up icon-chevron-down'); 
}); 

FIDDLE

+0

我真的很笨!謝謝 :) – mpgn

1

我也看着很多地方對這個答案(SIMPLE)

我發現這個

<div class="accordion-group"> 
         <div class="accordion-heading"> 
         <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#jai"> 
         <span class="pull-right"><i class="icon-chevron-up"></i></span> 
           Jai 
         </a> 
         </div> 

         <div id="jai" class="accordion-body collapse in"> 
         <div > 
         <div class="accordion-inner"> 
          body content 1 
         </div> 
         </div> 
         </div> 
        </div> 
        <div class="accordion-group"> 
         <div class="accordion-heading"> 
         <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo"> 
          <span class="pull-right"><i class="icon-chevron-down"></i></span> 
           jai2 
         </a> 
         </div> 

         <div id="collapseTwo" class="accordion-body collapse"> 
         <div> 
         <div class="accordion-inner"> 
          body content 2 
         </div> 
         </div> 
         </div> 
        </div> 
        <div class="accordion-group"> 
         <div class="accordion-heading"> 
         <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapse3"> 
          <span class="pull-right"><i class="icon-chevron-down"></i></span> 
           jai3 
         </a> 
         </div> 

         <div id="collapse3" class="accordion-body collapse"> 
         <div> 
         <div class="accordion-inner"> 
          body content 3 
         </div> 
         </div> 
         </div> 
        </div> 

// jQuery的--- //你需要有引導程序運行

$('div.accordion-body').on('shown', function() { console.log($(this).parent("div").find(".icon-chevron-down").html());// this will show you html selected 
$(this).parent("div").find(".icon-chevron-down").removeClass("icon-chevron-down").addClass("icon-chevron-up"); 

    }); 

    $('div.accordion-body').on('hidden', function() { console.log(this); 
     $(this).parent("div").find(".icon-chevron-up").removeClass("icon-chevron-up").addClass("icon-chevron-down"); 

//小提琴手view working example