I tried to use the methode explained in this answer in order to create a simple 3-point-menu that would let the user scroll to the respective sections.
Ended up with this code:
HTML
<body>
<nav id="nav">
<ul>
<li>
<a class="navLink" href="#home">HOME</a>
</li>
<li>
<a class="navLink" href="#info">INFO</a>
</li>
<li>
<a class="navLink" href="#pics">PICS</a>
</li>
</ul>
</nav>
<section id="home">
<!-- stuff -->
</section>
<section id="info">
<!-- stuff -->
</section>
<section id="pics">
<!-- stuff -->
</section>
</body>
JS
$('a.navLink').on('click', function(event) {
event.preventDefault();
var target = $(this.href);
if( target.length ) {
$("html, body").scrollTo(target, { duration: 1000, easing: "linear" });
}
});
Upon clicking any of the three links I end up with:
Uncaught Error: Syntax error, unrecognized expression:
http://localhost/meckerHP/#whatevervalueinhref
Even tried not using the href attribute at all by using an id for each link instead, which does eliminate the error message but leaves me with dead links.
I can't see any reason whatsoever why the method in the above-linked answer shouldn't be working, so any help is really appreciated.