jQuery offset top

I have this script but it is making the top about 50px from the actual top.  How do I change that so it is as close to the top as possible?

sections.each(function(e) {
    var top = $(this).offset().top,
        bottom = top + $(this).outerHeight();
    if (cur_pos >= top && cur_pos <= bottom) {
      nav.find('a').removeClass('active1');
      sections.removeClass('active1');

Open in new window

LVL 7
rgranlundAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
leakim971Connect With a Mentor PluritechnicianCommented:
replace :
var top = $(this).offset().top,
by :
var top = $(this).parent().offset().top,
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.