首页 > CSS自定义鼠标样式。JS获取鼠标坐标,实现提示气泡框跟随鼠标移动

CSS自定义鼠标样式。JS获取鼠标坐标,实现提示气泡框跟随鼠标移动

 

cursor: url(//img.58cdn.com.cn/resource/xxzl/captcha/pencil.png), default;

 ​​​​​​​

/*获取鼠标位置,让提示气泡框跟随鼠标*/
var sgTip=document.querySelector("#sgTip")
document.addEventListener("mousemove", e => {console.log(e.clientX, e.clientY);sgTip.style.left = e.clientX + 20 + "px", sgTip.style.top = e.clientY + 20 + "px";
});

更多相关: