This function should work like this: when I resize window too big it removes some classes from elements. If I resize small again, it does not give the classes back. Anyway, it is not working.
window.addEventListener('resize', listener, true);
var listen = function(element) {
this.leveys = window.innerWidth;
this.element = element;
this.listener = function(){
//If window width is over 1024, remove classes
if(leveys>1024){
this.element.classList.remove("mobinavi-auki-nappi");
document.querySelectorAll(".mobilesearch")
.forEach((element2) =>
element2.classList.remove("mobinavi-auki-haku") );
document.querySelectorAll(".menu-bar-items")
.forEach((element2) =>
element2.classList.remove("mobinavi-auki-hakulaatikko") );
// Remove eventlistener
window.removeEventListener('resize', listener, true);
}
}
};