function mouseEnter() {
this.style.color = "red";
}
function mouseLeave() {
this.style.color = "black";
}
var div = document.querySelectorAll('div');
for(var i = 0; i < div.length; i++) {
div[i].addEventListener('mouseenter', mouseEnter);
div[i].addEventListener('mouseleave', mouseLeave);
}
function mouseHandler(e) {
this.style.color = e.type === 'mouseenter' ? 'red' : 'black';
}
var div = document.querySelectorAll('div');
for(var i = 0; i < div.length; i++) {
div[i].addEventListener('mouseenter', mouseHandler);
div[i].addEventListener('mouseleave', mouseHandler);
}