$(window).scroll(function() { if ($(this).scrollTop() > 1){ $('header').addClass("sticky"); } else{ $('header').removeClass("sticky"); } }); $ ('header') apply to html or css tag class?
$(window).scroll(function() { if ($(this).scrollTop() > 1){ $('header').addClass("sticky"); } else{ $('header').removeClass("sticky"); } }); $ ('header') apply to html or css tag class?
I do not see the context but in this case to the html tag.
$(window).scroll(function() { if ($(this).scrollTop() > 100){ //Если окно прокручено больше чем на 100 писелей $('some_div').addClass(".some_class");// Добовляем .some_class } else{ $('some_div').removeClass(".some_class"); // Иначе убираем } }); - Alexander IschenkoThank you very much! I found the solution myself through document.getElementById
Source: https://ru.stackoverflow.com/questions/589275/
All Articles