[TASK] refactor queryselector
- ignore only #-hrefs
This commit is contained in:
parent
6302b59647
commit
3b81a6240b
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"gitea.repo": "ferienwohnung-wanderlust"
|
||||||
|
}
|
||||||
12
script.js
12
script.js
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user