Linking to a section of an Accordion from another page

后端 未结 4 2054
借酒劲吻你
借酒劲吻你 2020-12-14 17:51

I\'m using twitter-Bootstrap 2.04, and I\'m using the latest jQuery. I\'m trying to make a link that will go from one page to the page containing this accordion, and then ac

4条回答
  •  伪装坚强ぢ
    2020-12-14 18:15

    You can use the position of the accordion section. The following link opens the third accordion section on a twitter bootstrap (wordpress) accordion.

    Link Example: http://www.zfp-bauwesen.de/leistungen/ubersicht#3

    Javscript Code:

    $( document ).ready(function() {
    
     if (window.location.hash) {
       var AccordionSectionNumber = window.location.hash.substring(1);
       AccordionBodyID = $(".accordion .accordion-group:nth-of-type(" + AccordionSectionNumber + ") .accordion-heading a").attr('href')
          if (! (typeof AccordionBodyID === "undefined")) {
            $(AccordionBodyID).collapse('show');
            return true;
          }
        }
    
    });
    

提交回复
热议问题