diff --git a/jquery.nav.js b/jquery.nav.js index abc74ba..daf9d86 100644 --- a/jquery.nav.js +++ b/jquery.nav.js @@ -113,16 +113,16 @@ var self = this; var linkHref; var topPos; - var $target; - + var targets = []; + self.$nav.each(function() { linkHref = self.getHash($(this)); - $target = $('#' + linkHref); - - if($target.length) { - topPos = $target.offset().top; - self.sections[linkHref] = Math.round(topPos) - self.config.scrollOffset; - } + targets.push('#' + linkHref); + }); + $(targets.join(',')).each(function(){ + var $target = $(this); + topPos = $target.offset().top; + self.sections[$target.attr('id')] = Math.round(topPos) - self.config.scrollOffset; }); }, @@ -220,4 +220,4 @@ }); }; -})( jQuery, window , document ); \ No newline at end of file +})( jQuery, window , document );