Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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
Javascript 调用在Jquery中不作为链接函数使用_Javascript_Jquery - Fatal编程技术网

Javascript 调用在Jquery中不作为链接函数使用

Javascript 调用在Jquery中不作为链接函数使用,javascript,jquery,Javascript,Jquery,我有以下代码片段: $('#move').click(function () { $('#block').animate({ 'left': '+=50px' }, 500); }); function get_fx() { var store = console.log($(this).queue('fx').length); return store; } function trigger_it(param) { $(param).

我有以下代码片段:

$('#move').click(function () {
    $('#block').animate({
        'left': '+=50px'
    }, 500);
});

function get_fx() {
    var store = console.log($(this).queue('fx').length);
    return store;
}

function trigger_it(param) {
    $(param).trigger('click');
}

call_it = setInterval(function () {
    trigger_it('#move')
},
2000);

现在,在
$('#block')
上运行animate函数后,我希望
get_fx()
函数返回队列中仍在
$('#block')
中的动画数量,因此在animate函数之后有以下代码行:

.call(this , get_fx())
现在,这似乎确实有效,但让我向您展示我在控制台中得到的结果:

0 // 0 is displayed , which i guess is the correct result .. I am not sure . 
TypeError: $(...).animate(...).call is not a function // I get this error , I don't know why . 
现在有人能告诉我为什么会出现这个错误,我的调用函数是否在做它应该做的事情

编辑::我不想使用animate函数的回调选项,而是想在get_fx()上使用调用函数

函数支持回调函数。你可以利用这个。所以你可以这样用

        $('#move').click(function(){
            $('#block').animate({ 'left' : '+=50px' } , 500, function(){

                 get_fx();

            });

谢谢你的投票,这真的鼓励我学习更多,我是Jquery的新手,非常感谢你。不过也请回答这个问题。比如?@ArunPJohny谢谢,为什么我的代码中会显示错误?我创建了一个名为
call
的插件,它正在执行调用
get\u fx
的实际工作。如果这解决了问题,我可以将其作为answer@ArunPJohny我在你的小提琴里没有看到任何外部资源的插件,你没有使用调用函数是javascript,即prototype.call()?谢谢!但是我真的想使用call()函数。我知道回调选项。不过我会投票支持你的。
        $('#move').click(function(){
            $('#block').animate({ 'left' : '+=50px' } , 500, function(){

                 get_fx();

            });