I am trying to determine the top offset of an element and the console logs an error, even though JQuery's documentation says it should be written like this:
$('.myObject').offset().top
Error:
Uncaught TypeError: Cannot read property 'top' of undefined
Why does this happen? Any solution for the problem?
$('#myObject')? Using a class selector may be returning a set instead of one element.