MDN self-hosted library · e01.org

HTMLAnchorElement: hash property

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<a id="myAnchor" href="/en-US/docs/Web/API/HTMLAnchorElement/hash#examples">
  Examples
</a>
js
const anchor = document.getElementById("myAnchor");
anchor.hash; // '#examples'