Expand Specific Accordion from URL

后端 未结 1 1849
予麋鹿
予麋鹿 2021-01-23 07:41

If I use the adress \"www.xxxxxx.com/test.html#chgd\", the second accordion should be expanding.

I have used the source code from this website \'Bootstrap 3 expand accor

相关标签:
1条回答
  • 2021-01-23 07:50

    Try this:

        <script>
    
        jQuery(document).ready(function() {
            var url = document.location.toString();
            if ( url.match('#') ) {
                var hash = url.split('#')[1];
    
                // collapse the expanded panel
                $('#accordion .accordion-collapse').removeClass('in');
    
                // expand the requested panel
                $('#' + hash + '_c').addClass('in');
            }
        });
        </script>
    
    0 讨论(0)
提交回复
热议问题