Показать сообщение отдельно
  #1 (permalink)  
Старый 01.04.2020, 09:27
Профессор
Отправить личное сообщение для Сергей Ракипов Посмотреть профиль Найти все сообщения от Сергей Ракипов
 
Регистрация: 01.06.2010
Сообщений: 651

Разрешение экрана
Как сделать что бы запускалась функция при определённом разрешение
let navHover = document.querySelector(".nav_hover");
let navListDescop = document.querySelector(".navig:nth-child(10)");
let navListPhone = document.querySelector(".navig:nth-child(2)");
let descop = document.querySelector(".navig:nth-child(10)");
let phone =document.querySelector(".navig:nth-child(2)");


navHover.onmouseover = navOn;
navHover.onmouseout = navOff;
navListDescop.onmouseover = navListOn;
navListDescop.onmouseout = navListOff;

function navOn(){
	descop.style.top = "320px";
}
function navOff(){
	descop.style.top = "-360px";
}
function navListOn(){
	descop.style.top = "320px";
}
function navListOff(){
	descop.style.top = "-360px";
}

function test(){
	if (document.documentElement.clientWidth > 860) {
		navHover.onmouseover = navOn2;
		navHover.onmouseout = navOff2;
		navListPhone.onmouseover = navListOn2;
		navListPhone.onmouseout = navListOff2;

		function navOn2(){
			phone.style.marginTop = "0px";
		}
		function navOff2(){
			phone.style.marginTop = "-1500px";
		}
		function navListOn2(){
			phone.style.marginTop = "0px";
		}
		function navListOff2(){
			phone.style.marginTop = "-1500px";
		}
	}
}

test();


особенность в том navHover это один и тот же блок
Ответить с цитированием