diff options
author | lonzzi <lonzzi@qq.com> | 2022-06-11 01:39:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-11 01:39:16 +0300 |
commit | 7142de24cc211d52a4db0bb88c7ed10748ab397d (patch) | |
tree | 9b3116caae740e6e3590f53e980b823fc8e7f1d1 | |
parent | 9aa6b4925b232628496fa25971a38a7776054aec (diff) |
fix(article): TOC link not working when the heading starts with digits (#603)
-rw-r--r-- | assets/ts/smoothAnchors.ts | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/assets/ts/smoothAnchors.ts b/assets/ts/smoothAnchors.ts index 0718bf5..379eb39 100644 --- a/assets/ts/smoothAnchors.ts +++ b/assets/ts/smoothAnchors.ts @@ -23,7 +23,7 @@ function setupSmoothAnchors() { let targetId = aElement.getAttribute("href").substring(1); // The replace done on ':' is here for footnotes, as this character would otherwise interfere when used as a CSS selector. - let target = document.querySelector(`#${targetId.replace(":", "\\:")}`) as HTMLElement; + let target = document.getElementById(targetId.replace(":", "\\:")) as HTMLElement; window.history.pushState({}, "", aElement.getAttribute("href")); scrollTo({ top: target.offsetTop, behavior: "smooth" }); |