Cannot read property ‘top’ of undefined

It is very likely that this javascript function was placed before the actual html was loaded. Do something like add a condition

var container = $('.container');
if (container.length) {
  var content= container.offset().top;
  ...continue to set up the menu
}

Leave a comment

Your email address will not be published. Required fields are marked *