[TASK] refactor queryselector

- ignore only #-hrefs
This commit is contained in:
Christian Seyfferth 2020-04-22 22:33:29 +02:00
parent 6302b59647
commit 3b81a6240b
2 changed files with 8 additions and 7 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"gitea.repo": "ferienwohnung-wanderlust"
}

View File

@ -20,14 +20,12 @@ document.addEventListener('DOMContentLoaded', function () {
} }
} }
var hashAnchors = document.querySelectorAll("a[href^='#']"); var hashAnchors = document.querySelectorAll("a[href^='#']:not([href='#'])");
for (var i = 0; i < hashAnchors.length; i++) { for (var i = 0; i < hashAnchors.length; i++) {
if (hashAnchors[i].getAttribute("href") != "#") { hashAnchors[i].onclick = function () {
hashAnchors[i].onclick = function () { var target = this.getAttribute("href");
var target = this.getAttribute("href"); scrollToElement(target);
scrollToElement(target); return false;
return false;
}
} }
} }