Looking to create a dynamic header effect on scroll? I have two headers, menu1 by default and menu2 hidden with display:none.
In specific sections of my website, I've added a special attribute (data-ix="change-header") to trigger the header change. The desired effect is that as users scroll through the site and reach a section with data-ix="change-header", the headers should switch - hiding menu1 and showing menu2.
I currently have some code in place, but I'm struggling with implementing the scroll functionality. Any suggestions?
if ($(this).attr("data-ix") == "change-header"){
$("#menu1").css("display","none");
$("#menu2").css("display","block");
} else {
$("#menu1").css("display","block");
$("#menu2").css("display","none");
}
Here's an example of my HTML structure:
<header id="menu1"></header>
<header id="menu2"></header>
<div class="test" data-ix="change-header"></div>
<div class="test"></div>
<div class="test" data-ix="change-header"></div>
<div class="test" data-ix="change-header"></div>
<div class="test" data-ix="change-header"></div>
<div class="test"></div>
<footer></footer>
Any assistance would be greatly appreciated!