title: Bootstrap 3 expand accordion from URL
body: <p>Using Bootstrap 3, I'm trying to use sub-navigation anchor links (ie, index.php#wnsh) to expand a specified accordion and anchor down the page to the content. I've tried searching for examples but with little luck, likely because my accordion structure is different from the given BS3 example. Here's my HTML:</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Made a few updates to the code, but it still isn't opening the accordion specified by the hash. Any further thoughts?</p>
  
  <pre><code>            &lt;div id="accordion" class="accordion-group"&gt;                
                  &lt;div class="panel"&gt;
                      &lt;h4 id="cs" class="accordion-title"&gt;&lt;a data-toggle="collapse" data-parent="#accordion" data-target="#cs_c"&gt;Child Survival: Boosting Immunity and Managing Diarrhoea&lt;/a&gt;&lt;/h4&gt;
                      &lt;div id="cs_c" class="accordion-collapse collapse in"&gt;
                          &lt;p&gt;...&lt;/p&gt;
                      &lt;/div&gt;
  
                      &lt;h4 id="chgd" class="accordion-title"&gt;&lt;a data-toggle="collapse" data-parent="#accordion" data-target="#chgd_c"&gt;Child Health, Growth and Development: Preventing Mental Impairment with Iodine and Iron&lt;/a&gt;&lt;/h4&gt;
                      &lt;div id="chgd_c" class="accordion-collapse collapse"&gt;
                          &lt;p&gt;...&lt;/p&gt;
                      &lt;/div&gt;
  
                      &lt;h4 id="wmnh" class="accordion-title"&gt;&lt;a data-toggle="collapse" data-parent="#accordion" data-target="#wmnh_c"&gt;Women’s and Newborn Survival and Health: Iron Supplementation and Food Fortification&lt;/a&gt;&lt;/h4&gt;
                      &lt;div id="wmnh_c" class="accordion-collapse collapse"&gt;
                          &lt;p&gt;...&lt;/p&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>var elementIdToScroll =  window.location.hash;
  
  if(window.location.hash != ''){
    $("#accordion .in").removeClass("in");
    $(elementIdToScroll).addClass("in");
     $('html,body').animate({scrollTop: $(elementIdToScroll).offset().top},'slow');
  }
  </code></pre>
  
  <p>Thanks in advance. Any help would be appreciated.</p>