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

📅  最后修改于: 2021-11-25 03:43:03             🧑  作者: 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.                 
            
        
    
          


输出: