I have a one page website with a fixed menu button, the website has multiple sections:
<div class="fullscreen sec-1"></div>
<div class="fullscreen sec-2"></div>
<div class="fullscreen sec-3"></div>
By default the text for the button is white as the background colour of the first div is black. The colour of the second and third is white, so I want the colour of the button text to change to black when the scroll hits the top of the second div. I have managed to achieve this with if else but the height is fixed so when its on mobile devices the outcome is different because the height of the divs are all 100% fullscreen. I changed my code to:
$(document).ready(function() {
var button = $(".sec-1");
var offset = button.offset();
$(function () {
$(window).scroll(function () {
if ($(window).scrollTop() >= offset) {
$(".menu-button").css("color","black");
} else {
$(".menu-button").css("color","white");
}
});
});
});
Currently I'm having no luck, and I'm struggling to find an example to refer to so if anyone could help me or point me in the right direction I'd be very grateful.