0

にカーソルを合わせると、firstが表示されSecondます。

にカーソルを合わせるとSecond、表示されたSecondままになり、それ以外の場合は非表示になりSecondます。

私の問題は、ホバーfirstとホバーの間にありSecondSecond.

$(".second").hide("slow" );にホバーする前にを遅らせるにはどうすればよいsecondですか?

  $(".first").hover(
    function(){
      $(".second").show();
    },
    function(){
      $(".second").hide("slow" );
    }
  );

 $(".second").hover(
   function(){
     $(".second").show();
   },
   function(){
    $(".second").hide("slow" );
   }
 );
4

2 に答える 2

3

解決策は、タイマーを使用することですsetTimeout()

var $second = $(".second");
$(".first").hover(function () {
    clearTimeout($second.data('timer'));
    $second.stop(true, true).show();
}, function () {
    var timer = setTimeout(function () {
        $second.stop(true, true).hide("slow");
    }, 200);
    $second.data('timer', timer);
});

$(".second").hover(function () {
    clearTimeout($second.data('timer'))
    $second.stop(true, true).show();
}, function () {
    $second.stop(true, true).hide("slow");
});

デモ:フィドル

于 2013-11-07T03:51:57.543 に答える
0
$( "#clickme" ).click(function() {
$( "#book" ).hide( "slow", function() {
alert( "Animation complete." );
});
});
于 2013-11-07T03:54:21.843 に答える