Just wondering how to enable smooth scroll using full url.
This is the nav
<nav class="primary-nav">
<ul>
<li><a href="http://domainname.com/">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#services">Services</a></li>
<li><a href="http://domainname.com/contact">Contact</a></li>
</ul>
</nav>
Would like to use
<nav class="primary-nav">
<ul>
<li><a href="http://domainname.com/">Home</a></li>
<li><a href="http://domainname.com/#about">About</a></li>
<li><a href="http://domainname.com/#services">Services</a></li>
<li><a href="http://domainname.com/contact">Contact</a></li>
</ul>
</nav>
and this is the jQuery code used to scroll to sections on the page.
function smoothScroll(duration) {
$('a[href^="#"]').on('click', function (event) {
var target = $($(this).attr('href'));
if (target.length) {
event.preventDefault();
$('html, body').animate({
scrollTop: target.offset().top
}, duration);
}
});
}
Any help would be great thanks.