Unable to reference variable inside animate method
I have the following function:
$("#scroll1").click(function () {
var scrollId = $(this).attr("id");
$('html, body').animate({
scrollTop: ($(scrollId).offset().top-100)
}, 500);
})
When this fires I get: Uncaught TypeError: Cannot read property 'top' of undefined
This is on my variable reference in scrollTop: ($(scrollId).offset().top-100)
How can I reference the scrollId variable inside my .animate?