This uses the pathname property to detect if the character is a hash
<a href="https://example.com$[chr]foo" id=x></a>
document.getElementById('x').hash.includes('foo') && log($[i])
<a href="https://example.com#foo" id=x></a>