Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将jQuery切换设置回起始位置_Jquery - Fatal编程技术网

将jQuery切换设置回起始位置

将jQuery切换设置回起始位置,jquery,Jquery,我有以下代码在单击链接时显示/隐藏(切换)div: $('#complete-services-link').toggle( function () { $('#complete-services-box').fadeIn('fast'); }, function () { $('#complete-services-box').fadeOut('fast'); } ); #complete services box是正在显

我有以下代码在单击链接时显示/隐藏(切换)div:

$('#complete-services-link').toggle(
    function () {
         $('#complete-services-box').fadeIn('fast');
    }, 
    function () {
         $('#complete-services-box').fadeOut('fast');
    }
);
#complete services box
是正在显示/隐藏的div,通常您会再次单击链接以关闭该框,但如果我这样做,则您可以单击该框以关闭它,然后单击切换链接,我必须双击它,因为该链接正在侦听第二个函数
$(“#完整服务盒”).fadeOut('fast');

我想这样做,当我单击框时,上面的代码重新开始。我尝试了这个,但没有成功:

$('#complete-services-link').toggle(
    function () {
        $('#complete-services-box').fadeIn('fast');
    }, 
    function () {
        $('#complete-services-box').fadeOut('fast');
        $('#complete-services-box').click(function () {
             $('#complete-services-box').fadeOut('fast');
        });
    }
);
像这样使用
.stop(true,true)

$('#complete-services-link').toggle(
    function () {
         $('#complete-services-box').stop(true,true).fadeIn('fast');
    }, 
    function () {
         $('#complete-services-box').stop(true,true).fadeOut('fast');
    }
);