码迷,mamicode.com
首页 > 其他好文 > 详细

鼠标跟随提示框

时间:2016-12-12 20:16:48      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:display   鼠标   create   end   scroll   clientx   app   osi   事件   

鼠标移入某区域中鼠标右下角显示提示信息:

$(document).ready(function(){
// 创建一个div显示提示信息
var dropTitle = document.createElement("div");
dropTitle.id= "backdropTitle";
dropTitle.style.backgroundColor="#fff";
dropTitle.innerHTML="提示信息";
document.getElementsByTagName(‘body‘)[0].appendChild(dropTitle);

// 鼠标移入遮罩层事件
var backdropTitle = document.getElementById("backdropTitle");
var backdropBorderS = document.getElementsByClassName("backdrop-border");
backdropTitle.style.display = "none";
for(var i=0,len=backdropBorderS.length;i<len;i++){
backdropBorderS[i].onmousemove = function(evt) {
var oEvent = evt || window.event;
var scrollleft = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
backdropTitle.style.display = "block";
backdropTitle.style.position = "absolute";
backdropTitle.style.left = oEvent.clientX + scrollleft + 10 + "px";
backdropTitle.style.top = oEvent.clientY + scrolltop + 10 + "px";
backdropTitle.style.zIndex = "2060";
setTimeout(function(){
backdropTitle.style.display = "none";
},6000);
};
backdropBorderS[i].onmouseout = function (){
backdropTitle.style.display = "none";
}
}
});

鼠标跟随提示框

标签:display   鼠标   create   end   scroll   clientx   app   osi   事件   

原文地址:http://www.cnblogs.com/qhhw/p/6165507.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!