I have a json array of instructor data that feeds into a template and generates a "card" for each instructor. Each instructor contains a named anchor and I want to be able to link to the various generated anchors from an external page. i.e. instructors.htm#MrsTaylorGreen
It seems that by the time the cards have a chance to generate, all the browser's jump-to-anchor behavior is done.
I'm considering this bit of jQuery derived from here
// page load, draw instructor cards then...
// scroll to the named anchor if there is one
var anchor = document.location.href.split("#")[1];
if($("#" + anchor).length)
$('html, body').animate({
scrollTop: $("#" + anchor).offset().top
}, 2000);
Is this necessary? Or is there a more efficient alternative to link to dynamic anchors?