Open a specific accordion panel with an external anchor link

前端 未结 2 1242
温柔的废话
温柔的废话 2020-12-22 11:26

I have a bootstrap accordion setup and working fine.

I need to have links on external pages which will:

A) Take you to the specified panel within the accor

2条回答
  •  臣服心动
    2020-12-22 11:48

    You can try this:

    JS code: 
    
          $(function () {
                // check if there is a hash in the url
                if (window.location.hash != '') {
                    // show the panel based on the hash now.
                    $(window.location.hash + '.collapse').collapse('show');
                }
    
            });
    

提交回复
热议问题