As the user scrolls down the page, a sticky menu or floater bar appears. With the help of jQuery, I am able to apply the floater-bar class to the #menu-wrapper.
My objective is to also insert an image inside an anchor tag at the same time the floater-bar class is applied, ensuring that the logo appears on the floater bar.
if ($(window).scrollTop() > $header_top_pos) {
$("#menu-wrapper").addClass("floater-bar");
} else {
$("#menu-wrapper").removeClass("floater-bar");
}
I have experimented with the following code:
$("#menu-wrapper").append("<a href="#"><img src="image" /></a>");
I also tried using .add and .prepend methods.
However, this approach caused the entire script to fail, resulting in the floater-bar class not being applied to the menu.