I have some jQuery code like this
$(document).ready(function(){
$('.content-nav a').on('click',function(){
var str = $(this).attr("href");
var the_id = str.substr(1);
$("#container").animate({ scrollTop: $(the_id).offset().top }, 1000);
});
});
When I click the link i’m getting error like Uncaught TypeError: Cannot read property 'top' of undefined
Can someone tell me whats wrong?
I’m using jQuery 1.8.3 which is loaded from google api.
If
the_idis an id, then you need