Home >Web Front-end >JS Tutorial >js method to locate an anchor point
The anchor point can be set in the html page, and the anchor point definition
Html code
<a name="firstAnchor">&nsbp;</a>
Anchor point use
Html code
<a href="#firstAnchor">跳至第一个锚点</a>
But for js, how to complete an operation in js Then jump to a fixed anchor point on the page
location.href in js can jump to a certain url;
How to jump to (locate) a fixed anchor point
1. location.href = " #firstAnchor"; // firstAnchor is the anchor name
2, window.location.hash = "#firstAnchor"; // firstAnchor is the anchor name
After testing: hash will only jump to the first page of this page It works once, refreshing this page again will not work and href always works