0

私はこのコードを持っています:

 var shortcuts = $('#geo_shortcuts');
    shortcuts.find('li').hoverIntent(
        function () {
            // Open the Panel
            $(this).find('.geo_shortcuts_content').stop().animate({
                top: '-122'
            }, 300);
        },
        function () {
            //Close de Panel
            $(this).find('.geo_shortcuts_content').stop().animate({
                top: '0'
            }, 400);
        }
    );

マウスアウトの 2 秒後にのみ [閉じる] パネルを許可するにはどうすればよいですか? settimeout 関数を実行する必要があることはわかっていますが、方法がわかりません。

4

2 に答える 2

1

delay()メソッドを使用してみてください:

$(this).find('.geo_shortcuts_content').stop().delay(2000).animate({
    top: '0'
}, 400);
于 2012-06-22T11:25:04.560 に答える
0

タイマーを使用してそれを行うことができます

hideDelayTimer = null;
    shortcuts.find('li').hoverIntent(
        function () {
            // Open the Panel
            clearTimeout(hideDelayTimer);
            $(this).find('.geo_shortcuts_content').stop().animate({
                top: '-122'
            }, 300);
        },
    function () {
        //Close de Panel
        clearTimeout(hideDelayTimer);
        hideDelayTimer = setTimeout(function () {
            hideDelayTimer = null;
                $(this).find('.geo_shortcuts_content').stop().animate({
                    top: '0'
                }, 400);
        }, 2000);   

良い1日を

于 2012-06-22T11:25:02.593 に答える