Adding open/closed icon to Twitter Bootstrap collapsibles (accordions)

后端 未结 19 2311
失恋的感觉
失恋的感觉 2020-12-22 18:23

I\'ve set up this simple version of the Bootstrap accordion:

Simple accordion: http://jsfiddle.net/darrenc/cngPS/

Currently the icon only po

相关标签:
19条回答
  • 2020-12-22 19:19

    Shortest possible answer.

    HTML

    <a data-toggle="collapse" data-parent="#panel-quote-group" href="#collapseQuote">
        <span class="toggle-icon glyphicon glyphicon-collapse-up"></span>
    </a>
    

    JS:

    <script type="text/javascript">
     $(function () {
         $('a[data-toggle="collapse"]').click(function () {
         $(this).find('span.toggle-icon').toggleClass('glyphicon-collapse-up glyphicon-collapse-down');
         })
     })
     </script>
    

    And of course, you can use anything for a selector instead of anchor tag a and you can also use specific selector instead of this if your icon lies outside your clicked element.

    0 讨论(0)
提交回复
热议问题