var bl1 = document.querySelector('.block-1'), cl2 = document.querySelector('.class-2'); bl1.onmouseenter = e => cl2.style.zIndex = '10'; bl1.onmouseleave = e => cl2.style.zIndex = '0';