Hy, i'm new in js. I want to link my scrollTOp method to media queries via JS (window.matchMedia).
<script>
$(document).ready(function(){
$(window).scroll(function() {
if ($(document).scrollTop() > 458) {
$(".menu a").css("background-color", "#f8f8f8");
$(".menu").css("display", "none");
$(".sidenav").css("display", "block");
$(".closebtn").css("display", "block");
}
else {
$(".menu a").css("background-color", "#666");
$(".menu").css("display", "block");
$(".sidenav").css("display", "none");
$(".closebtn").css("display", "none");
}
});
});
</script>
I don't know how, please help :)
If I have understood correctly, you want to check if your
$(document).scrollTop() > 458
and if it matches a media query.To do that you can simply add :
More informations about window.matchMedia here and about the logical 'and' operator here.