You can use the window.location.hash method to get the hash:
The hash property contains the fragment identifier, including the hash ‘#’ sign for the current page.
The location hash property returns the fragment identifier, including the hash ‘#’ sign for the current page. For example:
Here, the location hash property would return the fragment identifier of #foo.
The window.location Property
The location interface represents the URL of the object to which it is. The changes that are done on it are reflected in the object to which it relates. The window.location is a reference to a location object representing the current URL of the document being displayed in that window.