📜  如何在Bootstrap中从URL扩展手风琴?

📅  最后修改于: 2021-05-25 10:53:35             🧑  作者: Mango

给定一个包含自举式手风琴的HTML文档,任务是根据在网页URL中传递的查询来扩展手风琴的特定部分。

方法:可以使用URL接口的hash属性来完成此任务。 URL接口的hash属性是USVString,包含“#”和URL的片段标识符。我们可以使用jQuery提取此哈希,并根据哈希字符串在特定的手风琴节上切换“ show”类。

示例:在此示例中,我们有一个具有三个部分的引导手风琴,分别具有ID的“ collapseOne”,“ collapseTwo”和“ CollapseThree”。要显示手风琴的特定部分,我们只需要添加即可。

To show the first section, 
https:///#collapseOne

To show the second section,
https:///#collapseTwo

To show the third section,
https:///#collapseThree
HTML


  

    
    
  
    
    
  
    
    
      
    
      
    

  

  
    
    
        
            
                

                                     

            
               
                   
                    Bootstrap is a free and open-source tool                     collection for creating responsive websites                     and web applications. It is the most popular                     HTML, CSS, and JavaScript framework for                      developing responsive, mobile-first web sites.                     Nowadays, the websites are perfect for all                      the browsers (IE, Firefox and Chrome) and                      for all sizes of screens (Desktop, Tablets,                     Phablets, and Phones). All thanks to Bootstrap                     developers – Mark Otto and Jacob Thornton of                      Twitter, though it was later declared to be                      an open-source project.                 
            
        
           
            
                

                                     

            
               
                                   
                    Bootstrap is a free and open-source tool                     collection for creating responsive websites                     and web applications. It is the most popular                     HTML, CSS, and JavaScript framework for                      developing responsive, mobile-first web sites.                     Nowadays, the websites are perfect for all                      the browsers (IE, Firefox and Chrome) and                      for all sizes of screens (Desktop, Tablets,                     Phablets, and Phones). All thanks to Bootstrap                     developers – Mark Otto and Jacob Thornton of                      Twitter, though it was later declared to be                      an open-source project.                 
            
        
                   
            
                

                                     

            
               
                                   
                    Bootstrap is a free and open-source tool                     collection for creating responsive websites                     and web applications. It is the most popular                     HTML, CSS, and JavaScript framework for                      developing responsive, mobile-first web sites.                     Nowadays, the websites are perfect for all                      the browsers (IE, Firefox and Chrome) and                      for all sizes of screens (Desktop, Tablets,                     Phablets, and Phones). All thanks to Bootstrap                     developers – Mark Otto and Jacob Thornton of                      Twitter, though it was later declared to be                      an open-source project.                 
            
        
    
          


输出: