ホームページ  >  記事  >  ウェブフロントエンド  >  javascript onmouseout solution_javascript スキル

javascript onmouseout solution_javascript スキル

WBOY
WBOYオリジナル
2016-05-16 18:23:051068ブラウズ

onmouseout のトリガーが敏感すぎるため、レイヤー内のテキストチェーンを通過する際に onmouseout イベントがトリガーされ、正常に表示できないことが判明しました。調べた結果、参考までに整理しました。

1.

コードをコピーします コードは次のとおりです:

< ;script type ="text/javascript">
関数 test(obj, e) {
if (e.currentTarget) {
if (e.popularTarget != obj) {
if ( obj != e.popularTarget.parentNode) {
alert(1);
}
}
} else {
if (e.toElement != obj) {
if ( obj != e.toElement.parentNode) {
アラート(1);
}
}
}

;
"test(this,event)" style="width:100px;height:100px;border:1px #666 Solid">
faddsf


2.
コードをコピー コードは次のとおりです。

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
};
var LeaveFun = function(o){
var _o = typeof o == "string" ? document.getElementById(o) : o;
return this == window? _o):LeaveFunext(_o , LeaveFun.prototype);
};
マウスリーブ : function(fn){
if(IE){
this.attachEvent( 'onmouseleave',fn) ;
}else{
this.addEventListener('mouseout',function(e){
tar = e.popularTarget;
if(!contains(this, tar) ){
fn .call(this);
}
},
}
これを返します; ').mouseleave(関数) ){document.getElementById('share_customerdiv').style.display ='none';})


3. 最も単純ですが、一部のシステムでは多少異なります。




コードをコピー


コードは次のとおりです:
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
前の記事:スピン ボタンのカスタム テキスト ボックスの値は、j​​Query_jquery に基づいて増減します。次の記事:スピン ボタンのカスタム テキスト ボックスの値は、j​​Query_jquery に基づいて増減します。

関連記事

続きを見る