解决IE下重叠div对mouseover事件的穿透方法之
(2012-08-24 17:13:30)
标签:
杂谈 |
分类: javascript |
现象: 两个并列关系的Div(没有父子关系),但是两个Div在位置上面有重叠,当鼠标在两个div重叠部分的时候,会触发下层div的mouseover事件(IE),从而触发上层div 的mouseleave事件。
this._ul.mouseenter(function(e){//JS里面访问 类成员方法必须 使用thisthat._open(jq(this));e.stopPropagation();}).mouseleave(function(e){//为了防止IE下 div重叠时候对鼠标事件的穿透(非冒泡)//判断 鼠标不在ul中的时候才隐藏排序列表var temp=jq(this);var temp_left=temp.offset().left;var temp_width =temp.width();var temp_top=temp.offset().top;var temp_height=temp.height();var _dir_x = (e.clientX>temp_left)&&(e.clientX<temp_left+temp_width);var _dir_y = (e.clientY>temp_top)&&(e.clientY<temp_top+temp_height);if(!_dir_x || !_dir_y){that._close(jq(this));}e.stopPropagation();});
1.html
2.mouseover
3.Z-index 仅能在定位元素上奏效(例如 position:absolute;)! z-index=-1;
4.Bug
5.JQuery

加载中…