In case that there is an objects called (id) "ABC123", I want to scroll down automatic to that object. That works fine if this object exist. But if not, I receive an error: "TypeError: $(...).offset(...) is undefined"
My code should avoid this error, but doesn't work:
if(typeof($('#ABC123')) != 'undefined') {
$('html, body').animate({ scrollTop: ($("#ABC123").offset().top-100) }, 0).scroll();
}