var last_element=null;
track_mouse = (e) => {
const get_current_element = (e) => {
let x = e.clientX, y = e.clientY;
return document.elementFromPoint(x, y);
}
const highlight = (element) => {
element.style.outline = '#f00 solid 2px'
}
const remove_height_light = (element) => {
element.style.removeProperty('outline')
}
let elementMouseIsOver = get_current_element(e)
if (elementMouseIsOver === last_element) {
//当鼠标在元素内部移动的时候
return
}
if (last_element != null) {
remove_height_light(last_element)
}
highlight(elementMouseIsOver)
last_element = elementMouseIsOver
}
window.addEventListener("mousemove",track_mouse,true)