Reputation: 313
I want to be able to smooth scroll to a specific div using its id but my current script isn't correct. Can anyone see where my error is?
Here is my fiddle for reference here.
<script>
$(document).ready(function() {
$('a').click(function(){
$('html, body').animate({
scrollTop: $( $.attr(this, 'href') ).offset().top
}, 5000);
return false;
});
});
</script>
Thanks.
Upvotes: 0
Views: 63
Reputation: 2098
no need to add script tag in jsfiddle. Try with this fiddle. http://jsfiddle.net/wn6rv94t/1/
Removed<script></script>
Upvotes: 1