Solved

jQuery offset top

Posted on 2016-11-02
1
16 Views
Last Modified: 2016-11-02
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

0
Comment
Question by:rgranlund
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 41871150
replace :
var top = $(this).offset().top,
by :
var top = $(this).parent().offset().top,
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now