根据鼠标位置显示提示框


//触发显示提示框的事件
function b(){
//获取要显示的元素
var c=document.getElementById('c');
//显示
c.style.display='block';
//定位
c.style.position='fixed';
//距窗口左侧的距离
c.style.left=event.clientX+10+'px';
//距窗口右侧的距离
c.style.top=event.clientY+10+'px';
}

event.clientX:鼠标横向位置
event.clientY:鼠标纵向位置

Firefox浏览器不支持event.clientY和event.clientX获取鼠标位置,需要自己创建一个event,创建方法在另一篇博客里面
创建event对象:       https://www.cnblogs.com/PHP0222wangdong/p/11363115.html

原文地址:https://www.cnblogs.com/PHP0222wangdong/p/11329973.html