I apologize if this question has already been answered. I\'ve tried searching for solutions but could not find any that suited my code. I\'m still new to jQuery.
I h
Check if the jQuery object contains any element before you try to get its offset:
var nav = $('.content-nav'); if (nav.length) { var contentNav = nav.offset().top; ...continue to set up the menu }