如果在 body 标签上使用 mousemove
事件。是否可以获取当前鼠标经过的html中的什么元素。
$('body').mousemove(function (e) {
var details = e; // can e.something return what element the mouse cursor is over?
console.log(details);
});
最佳答案
你可以使用 event.target
获取id使用
var id = event.target.id;
use也可以检查using this
var $target = $(event.target);
if ($target.is("a")) {
}
关于javascript - 通过 body 上的 mousemove 事件获取鼠标经过的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16560876/