I am trying to make a button for traversing down my page by using .parent, .next, and .find and this is getting an error
Uncaught TypeError: Cannot read property 'top' of undefined
html:
<div id="mainbody">
<div class="hero-unit">
<div class="next"></div>
</div>
<div class="index-block">
<div class="next"></div>
</div>
<div class="index-block">
<div class="next"></div>
</div>
<div class="index-block">
<div class="next"></div>
</div>
</div>
js:
/********************************
/ SCROLL TO NEXT
/*******************************/
$(document).ready(function(){
$('.next').on("click", function() {
var next;
next = $('#mainbody').parent().next().find(".index-block");
$('html,body').animate({ scrollTop: next.offset().top + 65}, 1000);
});
});