質問

私は、以下の問題です。ように簡単なjQueryコンテンツは、現在取り扱って何かと不思議。時には毎回mouseoverの要素のイベントのためにマウスおよびマウスの行動の両方でカーソルを合わせ、ツールチップが消えてもい手にな 多く の点滅一sec)を指定するフィールドです。が私のコードです。

  var hint = $('<div id="hint-wrap"><div id="hintbox-top"><div id="hintbox-bottom"><div id="hintbox-topleft"><div id="hintbox-bottomleft"><div id="hint-innerwrap"><div id="hint"></div></div></div></div></div></div></div>'); // Funny I know :-D

  hint.hide();
  $('body').append( hint ); // I append it

  $('.hashint').hover(function(e){   

// Set position to cursor's
hint.css( 'left', e.pageX );
hint.css( 'top', e.pageY - 60 );

// animated append
hint.css( 'opacity', 0.2 );
hint.show();
hint.animate( { 'opacity' : 1 }, 100 );

// set text
$( "#hint" , hint).html( $( '#' + $(this).attr( 'id' ) + '-hint' ).html() ); 

 },
 function(){ // there is the problem
    hint.hide();
  });

のHTML:

<div id="usernamelabel-hint" class="hinttext">Lorem Ipsum is simply dummy text of the printing and type.Lorem. <a href="#">Sign up!</a></div> <!-- This is hint text (and code) -->
<p><label><span class="hashint" id="usernamelabel">Username</span><span class="asterisk">*</span></label> <!-- ... stuff --> </p>

ください、誰もがなぜそうなのでマウスイベントがトリガや隠れマイボックス?

もちろんOndrej

役に立ちましたか?

解決

それはあなたのツールチップ-divのは、あなたのトリガのdivを重ねていること、だろうか?その場合、表示されるツールチップ-divが少なくともそれはいくつかのdivを前に私に起こったものだ...トリガーのdivのmouseleaveをトリガします。私は目に見えないトリガーのdivにすべてを重ねることによって、その問題を解決 - とても美しいではないが、私のために働いて..

他のヒント

最初に、なぜあなただけのHTMLのためのヒントのHTMLドキュメント?
のCSSが利用できるようになります。表示無?
そのときにヒントを使えばできます hint.show または hint.fadeIn.

まだ利用 $.mouseenter$.mouseleave.

例:

$.('#usernamelabel-hint').mouseenter(function() { 
  // show or fade inn hint text
});

$.('#usernamelabel-hint').mouseleave(function() {
  // Hide or fade out hinttext
});
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top