Seeking assistance with creating a function that will add a 'sticky' class to the menu when the user scrolls down to the middle, and then append a div when the 'sticky' class is present. Currently facing issues where the div keeps appending as I scroll and it remains even when scrolling back to the top. Any help or suggestions would be greatly appreciated.
jQuery(window).scroll(function(){
if(jQuery('.main-menu-top').hasClass('sticky')){
jQuery('.main-menu-top').append('<div id="checkout_sticky"></div>');
}else{
/*I want to hide the checkout_sticky, try hide(), doesn't work*/
});