$(window).on('hashchange', sendHash) code example
Example: js detect hash change
// Event listener
window.addEventListener("hashchange", e=>console.log('changed'), {});
// Event handler
window.onhashchange = e => console.log('changed');
// HTML event handler
<body onhashchange="funcRef();">