jQuery toggle element on scroll

By June 3, 2015 code, jquery, scroll


$(function() {
//caches a jQuery object containing the element
var element = $(".toggleElement");
$(window).scroll(function() {
var scroll = $(window).scrollTop();

if (scroll >= 500) {
header.removeClass('clearElement').addClass("colorElement");
} else {
header.removeClass("colorElement").addClass('clearElement');
}
});
});

Bottom Text Here