重写鼠标悬停事件(针对IE)
来源:互联网 发布:淘宝为什么不能改名字 编辑:程序博客网 时间:2024/06/15 12:36
在IE下,鼠标悬停只是几秒,解决内容过多时完整查看
例如
<div class='containt'> <!-- 显示title begin--> <span class='title_show' style='position: absolute;padding:10px; display:none;background:#edeef0; border: solid 1px #999999;border-radius:5px; z-index:9999'></span> <!-- 显示title end--> <div title='this is title' clss='mydiv'></div></div>
js事件
$(".mydiv").on("mouseover",this.proxy(this.title_show)).on("mouout",this.proxy(this.title_hide)); /** * 鼠标悬停事件处理 */ title_show:function(e){ e.preventDefault(); e.stopPropagation(); //获取当前的x坐标值 function pageX(elem){ return elem.offsetParent? (elem.offsetLeft+pageX(elem.offsetParent)):elem.offsetLeft; }; //获取当前的Y坐标值 function pageY(elem){ return elem.offsetParent?(elem.offsetTop+pageY(elem.offsetParent)):elem.offsetTop; }; function split_str(string,words_per_line) { var output_string = string.substring(0,1); //取 出i=0时的字,避免for循环里换行时多次判断i是否为0 for(var i=1;i<string.length;i++) { if(i%words_per_line == 0) { output_string += "<br/>"; } output_string += string.substring(i,i+1); } return output_string; }; this.title_value = ''; var span=e.target; var div=$(".title_show")[0]; this.title_value = span.title; div.style.left = pageX(span)+50+'px'; div.style.top = pageY(span)-230+'px'; var words_per_line = 40; //每行字数 var title = split_str(span.title,words_per_line); //按每行25个字显示标题内容。 div.innerHTML = title; div.style.display = ''; span.title = ''; //去掉原有title显示。 }, title_hide:function(e){ var span=e.target; var div=$(".title_show")[0]; span.title = this.title_value; div.style.display = "none"; }
this.proxy是this对象的转移
阅读全文
0 0
- 重写鼠标悬停事件(针对IE)
- 鼠标悬停事件
- 笔记-鼠标悬停事件
- css 鼠标悬停事件
- hover鼠标悬停事件
- unity 鼠标悬停事件
- selenium 鼠标悬停事件
- 鼠标悬停,延后触发事件
- JS鼠标事件(监听鼠标点击/释放,鼠标悬停/离开等)
- 重写鼠标事件
- jQuery鼠标悬停事件.hover()用法说明
- echars 自定义触发鼠标悬停事件
- 用UGUI做一个鼠标悬停事件
- python中的selenium中的鼠标悬停事件!
- Javascript:DOM事件(监听鼠标点击/释放,鼠标悬停/离开等)
- 鼠标悬停在文本框末尾,兼容ie、ff、opera
- IE 和 FF 下都好用的鼠标悬停变色
- 鼠标悬停
- QT之多线程学习笔记
- MYSQL导入数据出现The MySQL server is running with the --secure-file-priv
- struct和typedef struct
- 企业安全丨旧瓶新酒之ngx_lua & fail2ban实现主动诱捕
- 关于android 导入第三方.so库文件在低版本Android手机上正常使用,在5.0版本的手机上就出现闪退
- 重写鼠标悬停事件(针对IE)
- spring boot整合RabbitMQ(Direct模式)
- Winsock编程实例
- unity 贪吃蛇作战—2
- Python 字典(dict) 操作基础
- 顺序表的实现,插入,删除,定位,合并,打印
- Activity启动流程分析
- 在Spring Boot中使用@Scheduled实现定时任务
- 关于js中几种遍历方法性能的测试