I'm new to utilizing jQuery and currently facing a challenge in determining the correct offset for a specific div element within the body. My goal is to make this particular div stick to its position as I scroll down past its designated top offset.
After following a tutorial at https://www.youtube.com/watch?v=utonytGKodc, I managed to implement the sticky functionality successfully. However, there is an issue with a metaslider located in my header which isn't factored into the offset calculations, resulting in the sticky behavior triggering too early...
Is it possible for me to manually incorporate the slider's coordinates (offset) into the calculation for the desired sticky element?
var offerteOffset = jQuery(".agendawrap").offset().top //+ metaslider coordinates??;
alert(offerteOffset);
jQuery(window).scroll(function() {
var scrollPos = jQuery(window).scrollTop();
if (scrollPos >= offerteOffset) {
jQuery(".agendawrap").addClass("fixed");
} else {
jQuery(".agendawrap").removeClass("fixed");
}
});