$(window).scroll(function() {
if (($(this).scrollTop() > 102) && ($(window).width() > 768)) {
$('header').addClass("header-scroll");
}
else{
$('header').removeClass("header-scroll");
}
});
I’m trying to make code that adds classes to the header on a page when it’s scrolled on desktop only. how to do it right?
3
Answers
Here is the code you can use:
Reference this answer : How to detect a mobile device using jQuery
you can use this code: