国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

javascript onmouseout 解決辦法

2019-11-21 00:21:14
字體:
供稿:網(wǎng)友
onmouseout 發(fā)現(xiàn)它的觸發(fā)太敏感,當(dāng)經(jīng)過層內(nèi)文字鏈時(shí),即觸發(fā)onmousetout事件,功能不能正常顯示,經(jīng)過一番搜索,整理出來,供大家參考。

1、
復(fù)制代碼 代碼如下:

<script type="text/javascript">
  function test(obj, e) {
    if (e.currentTarget) {
  if (e.relatedTarget != obj) {
   if (obj != e.relatedTarget.parentNode) {
  alert(1);
  }
  }
  } else {
  if (e.toElement != obj) {
  if (obj != e.toElement.parentNode) {
  alert(1);
  }
  }
  }
  }
</script>
  <div onmouseout="test(this, event)" style="width:100px;height:100px;border:1px #666 solid">
    <span style="margin:5px;width:100%;height:100%;border:1px #ff0000 solid">faddsf</span>  </div>

2、
復(fù)制代碼 代碼如下:

  var LeaveFunext = function(t,f){for(var p in f){t[p]=f[p]} return t};
  var IE = '/v' == 'v';
  var contains = function(wrap,child){
  if(IE) return wrap.contains(child);
  while(child && typeof(child.parentNode) != "undefind"){
  if(wrap == child) return true;
  child = child.parentNode;
}
return false;
  };
  var LeaveFun = function(o){
  var _o = typeof o =="string" ? document.getElementById(o) : o;
  return this == window ? new LeaveFun(_o):LeaveFunext(_o, LeaveFun.prototype);
  };
  LeaveFun.prototype = {
  mouseleave : function(fn){
  if(IE){
  this.attachEvent('onmouseleave',fn);
  }else{
this.addEventListener('mouseout',function(e){
tar = e.relatedTarget;
if(!contains(this, tar)){
fn.call(this);
}
  }, false);
  }
  return this;
  }
  };
  //調(diào)用
  LeaveFun('share_customerdiv').mouseleave(function(){document.getElementById('share_customerdiv').style.display ='none';})

3、最簡單,但在部分系統(tǒng)上會(huì)有輕微閃爍。
復(fù)制代碼 代碼如下:

<div style="z-index: 11; " onmouseout="this.style.display='none'" onmouseover="this.style.display='block'" >
<b class="STYLE19">更多此人的...</b>
<a class="STYLE8" >留言板</a>
<a class="STYLE8" >好友</a>
<a class="STYLE8"></a>
</div>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 舞钢市| 靖边县| 墨玉县| 蒙阴县| 加查县| 修水县| 武山县| 永泰县| 聂拉木县| 崇文区| 迁安市| 启东市| 苍梧县| 扎囊县| 新竹县| 徐州市| 衡阳县| 鹤岗市| 永平县| 内江市| 崇阳县| 海丰县| 安义县| 铁岭县| 贞丰县| 浦城县| 馆陶县| 崇仁县| 依兰县| 简阳市| 怀来县| 壶关县| 尚志市| 灵丘县| 四平市| 应用必备| 会东县| 清水河县| 卓尼县| 芦溪县| 五莲县|