I have a page with some tabs. I created links with a hash to load that tab's content automatically. All works fine in that regard, but each time I use the hash URL it loads the correct content, but loads the page at the top of the content it loaded, not the top of the page. I want to disable this, but keep the correct content loading. ScrollTop doesn't seem to do anything.
$(function(){
var Div1 = $('#Div1');
var Div2 = $('#Div2');
var Div3 = $('#Div3');
if (location.hash === "#Show_Div1") {
$(Div1).removeClass('is-visuallyhidden').siblings().addClass('is-visuallyhidden');
$(this).scrollTop(0);
} else if (location.hash === "#Show_Div2"){
$(Div2).removeClass('is-visuallyhidden').siblings().addClass('is-visuallyhidden');
$(this).scrollTop(0);
} else if (location.hash === "#Show_Div3"){
$(Div3).removeClass('is-visuallyhidden').siblings().addClass('is-visuallyhidden');
$(this).scrollTop(0);
}
});