0%

Solution to the problem of invalid anchor links within a tag page

  • Chinese:

I recently encountered a problem with the anchor links in the a tab not jumping during the course of a project, and I checked the id and stuff and it was fine.
Maybe this shouldn’t have been a problem in the first place. After searching on the Internet for a long time, I finally found a not very complicated alternative in a very complicated article.

Bind the following onclick event to the a tag

1
document.getElementById('divid').scrollIntoView();

In this way, it is possible to achieve an effect similar to an anchor link in a page without affecting the URL address.