fix a bug in toc selector

This commit is contained in:
Junyi Hou 2024-03-18 16:58:35 +08:00
parent cf18ae777f
commit 3cd15e9a35

View File

@ -17,16 +17,19 @@
<script>
document.querySelector(".toc").addEventListener("click", function () {
if (event.target.tagName !== "A") {
event.preventDefault();
if (this.open) {
this.open = false;
this.classList.remove("expanded");
} else {
this.open = true;
this.classList.add("expanded");
var toc = document.querySelector(".toc");
if (toc) {
toc.addEventListener("click", function () {
if (event.target.tagName !== "A") {
event.preventDefault();
if (this.open) {
this.open = false;
this.classList.remove("expanded");
} else {
this.open = true;
this.classList.add("expanded");
}
}
}
});
});
}
</script>