Changing font awesome color on scroll?

I am using the bars function on my mobile menu, and want it to change to black when I scroll. I have this script:

<script>
$(function () {
	$(document).scroll(function () {
		var $nav = $(".navbar-fixed-top");
		$nav.toggleClass('scrolled', $(this).scrollTop() > $nav.height());
	});
});
</script>

Which changes the background colour of the header on scroll, how can I change the colour of a class?

Thanks!

The easiest and quickest method to implement would probably be the .onscroll method. From here you would take the element/s and change its style attribute.

Mozilla Docs

Hope this helps.

1 Like