I have a slide toggle that is working at the moment,but what i want also is to be able to open automatically based on the hash in the URL
so for example if i have something like www.website.com/#Compliance
it should open the block after href=“#compliance”
here is my HTML
<h2 class="trigger"><a href="#Partnering and Business Development">Partnering and Business Development</a></h2>
<div class="toggle_container">
<div class="block">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Quisque vel nisi id erat hendrerit rutrum. Curabitur ut arcu erat.
Aenean quis nunc in erat blandit mattis. Aenean quis neque lorem.
Phasellus aliquet, massa tincidunt vehicula ullamcorper, lacus orci
faucibus tortor, id facilisis lacus leo nec felis. Vestibulum faucibus
</p>
</div>
</div>
<h2 class="trigger"><a href="#Fundraising">Fundraising</a></h2>
<div class="toggle_container">
<div class="block">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Quisque vel nisi id erat hendrerit rutrum. Curabitur ut arcu erat.
Aenean quis nunc in erat blandit mattis. Aenean quis neque lorem.
Phasellus aliquet, massa tincidunt vehicula ullamcorper, lacus orci
faucibus tortor, id facilisis lacus leo nec felis. Vestibulum faucibus
</p>
</div>
</div>
here is my JS
$(document).ready(function(){
//Hide (Collapse) the toggle containers on load
$(".toggle_container").hide();
// Check for hash value in URL
var hash = window.location.hash;
var href = $('h2.trigger').find('a').each(function(){
var href = $(this).attr('href');
if(hash==href){
$(this).toggleClass("active").next().slideToggle("slow");
}
});
//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
$("h2.trigger").click(function(){
$(this).toggleClass("active").next().slideToggle("slow");
});
});