JavaScript
25
Вклад в тег
var colorsBig = document.querySelector('.big-color');
var colorsElements = document.querySelectorAll('ul li');
for(var colorElement of colorsElements) {
colorElement.onmouseenter = function(event) {
colorsBig.classList.remove('hidden');
var targetX = event.target;
var location = targetX.getBoundingClientRect().x;
colorsBig.style.left = location + 'px'
}
colorElement.onmouseleave = function() {
colorsBig.classList.add('hidden');
}
}