I would like to remove the class .active of two elements (#information, #content) once the window has been scrolled for 50px. Here's the code how I would like to add the class .active and remove it again - sadly it doesn't work. Maybe somebody can help me?
$("#button").click(function(e) {
e.preventDefault();
$("#information, #content").addClass("active");
});
$(window).scroll(function(){
if ( (!$(window).scrollTop()>50) || (!$("#information").hasClass("active")) )
{
$("#content").removeClass("active");
$("#information").removeClass("active");
}
});
Try:
$("#button").click(function(e) {
e.preventDefault();
$("#information, #content").addClass("active");
});
$(window).scroll(function(){
if($(window).scrollTop()>50) && $("#information").hasClass("active") )
{
$("#content").removeClass("active");
$("#information").removeClass("active");
}
});