let imgArticle = document.querySelector(".img_article");
let imgArticle_2 = document.querySelector(".img_article_2");
let explanation = document.querySelector(".explanation_defolt");
function explanationSticky(){
let scrollTop;
if (window.pageYOffset){
scrollTop = window.pageYOffset;
}
else {
if (document.documentElement.scrollTop){
scrollTop = document.documentElement.scrollTop;
}
else{
scrollTop = document.body.scrollTop;
}
}
function myFunction(x){
if(x.matches){
if(scrollTop >= 220 & scrollTop <= 820){
explanation.classList.remove("explanation_defolt");
explanation.classList.add("explanation_scroll");
}
else{
explanation.classList.add("explanation_defolt");
explanation.classList.remove("explanation_scroll");
}
}
else{
explanation.classList.remove("explanation_scroll");
explanation.classList.remove("explanation_defolt");
explanation.classList.add("explanation_mobile");
}
}
let x = window.matchMedia("(max-width: 860px)");
myFunction(x);
x.addListener(myFunction);
window.addEventListener("scroll", explanationSticky);
У меня
Unexpected end of input в последней строке
и правильно ли соблюден синтаксис