I'm getting a jquery error : Uncaught TypeError: Cannot read property 'top' of undefined
I am assuming I have to add a check to my code but it still gives the error. I'm wondering how to add the check properly
jquery:
var topOfElement = $('.references-list-container-outer').offset().top;
$(window).scroll(function () {
if ($(window).scrollTop() > topOfElement) {
$('.article-nav-spotlight-chylers-page').fadeOut();
} else {
$('.article-nav-spotlight-chylers-page').fadeIn();
}
});