I've got a simple jQuery if statement that immediately scrolls down to a section with the class 'registration' once the page is loaded. That works, but I need it to have it go another 156px more due to the sticky header. Otherwise, the top portion of the section won't be visible.
Page in question: https://acumedstaging.wpengine.com/registration
This is what I currently have:
if(top.location.pathname === '/registration/'){
$('html,body').animate({
scrollTop: $(".registration").offset({ top: 156 })
});
}
I've tried some other methods with .offset as well but no luck so far. Any idea how to make this function.... function?
This isn't the correct way to use .offset(), what this code is actually trying to do is set the offset of the elements matched by .registration:
$(".registration").offset({ top: 156 })
.offset() with no arguments returns an object which looks like {top: 400, left: 25} which represents the offset of the element.
Instead use:
$(".registration").offset().top + 156 + 'px'