0
I have a problem on a site I’m creating, the scrolling effect I did on Js is not working properly, I put a console.log() to know if at least the event is running and is, the only problem is that scroll does not happen. If you can help me graduate.
MENU
<ul class="navbar-menu">
<li><a class="scrolling" href="#home">MENU 1</a></li>
<li><a class="scrolling" href="#portfolio">MENU 2</a></li>
<li><a class="scrolling" href="#videos">MENU 3</a></li>
<li><a class="scrolling" href="#contact">MENU 4</a></li>
</ul>
SCRIPT
<script type="text/javascript">
$(document).ready(function () {
$('.scrolling').click(function (e) {
var linkHref = $(this).attr('href');
console.log($(linkHref).offset().top);
$('html, body').animate({
scrollTop: $(linkHref).offset().top
}, 1000);
e.preventDefault();
});
});
P.S.: My version of jquery is 3.1.1.
If you need more information please let me know.
Hug.
Post the rest of the html please
– Guilherme Nascimento
I played your code on this one fiddle Is working correctly. Make sure you have set the ids correctly in the elements you want to achieve.
– Bruno Carvalho