If element is hidden width display:none; .offset() will return undefined, always check if object exists before getting property