TypeError: undefined is not an object only in Safari and iOS
<p>My below codes are working fine in Chrome but it gives the following error in Safari. Is there any solution to fix it.</p>

<pre><code>jQuery('.mk-responsive-nav &gt; li &gt; a').click( function() {
   var href = jQuery(this).attr('href').replace('#', '');
   jQuery(window).scrollTop( jQuery("section[data-anchor='" + href + "']").offset().top );
   console.log( jQuery("section[data-anchor='" + href + "']").offset().top  );
});
</code></pre>

<p>Safari error:</p>

<p>TypeError: undefined is not an object (evaluating 'jQuery("section[data-anchor='" + href + "']").offset().top')</p>