2

要素にカーソルを合わせると発生する jquery ホバー イベントがあります。問題は、要素の上に何度もホバーすると、イベントがキューに入れられ、要素の上にホバーしてホバーする速度と時間に応じて、要素が点滅したままになることがあります。このキューイングをなくすために、イベントの伝搬を停止したいと考えています。

$('.pui-search-item').hover( function() {
        $(this).find('.pui-actions').show('fade');
    }, function(){
        $(this).find('.pui-actions').hide('fade');

    });

これについてどうすればよいでしょうか。さまざまな伝播機能を試してみましたが、効果はありませんでした。

前もって感謝します。

4

3 に答える 3

7

Try this:

$('.pui-search-item').hover( function() {
        $(this).find('.pui-actions').stop(true, true).show('fade');
    }, function(){
        $(this).find('.pui-actions').stop(true, true).hide('fade');

    });

Here is more info about stop() http://api.jquery.com/stop/

于 2011-05-13T13:15:03.577 に答える
3

アニメーションの前に関数呼び出しを追加してstop(true)、キューをリセットします。

于 2011-05-13T13:14:19.903 に答える
1

このリンクを試してください。

実装は次のように変更されます。

$('.pui-search-item').hover(function() {
  $(this).find('.pui-actions').stop(true, true).fadeOut();
}, function() {
  $(this).find('.pui-actions').stop(true, true).fadeIn();
});
于 2011-05-13T13:17:54.507 に答える