This could be easily done on page-load, by simply looking for a hash in the URL:
$(document).ready(function(){
// the #-prefixed portion of the URL that serves
// as a fragment identifier for the document, from
// www.example.com/page#fragment
// document.location.hash would return #fragment
let hash = document.location.hash;
// because the hash identifies a fragment of
// the document by its id, and the '#' character
// specifies an id-selector in CSS we pass that
// value to jQuery to select the correct element
// and call the click() method - without arguments -
// to trigger a click event:
$(hash).click();
});
Alternatively, the CSS selector of :target selects the element targeted by the hash, so it's also possible to use:
$(document).ready(function(){
$(':target').click();
});
References: