I am trying to implement a script that will allow me to scroll to my navigation and then change the class of the navigation, however, it is not working as expected.
$(window).scroll(function() {
if ($(window).scrollTop == $('.menu_nav').offset().top) {
$('.menu_nav').removeClass('menu_nav').addClass('nav_scroll');
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="menu_nav">
<ul>
<li><a href="#">About Me</a>
</li>
<li><a href="#">Portfolio</a>
</li>
<li><a href="#">Contact Me</a>
</li>
</ul>
</div>