<a id="myAnchor" href="/en-US/docs/Web/API/HTMLAnchorElement/hash#examples">
Examples
</a>HTMLAnchorElement: hash property / notebook
HTMLAnchorElement: hash property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const anchor = document.getElementById("myAnchor");
anchor.hash; // '#examples'