jquery后执行回调每次迭代 [英] execute callback after jquery each iteration

查看:131
本文介绍了jquery后执行回调每次迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在每次迭代完成后正确执行函数f,以便我可以计算该特定类的元素?

How can I properly execute the function f when the each iteration has finished so I can count the elements with that particular class?

这样就得到0而不是16。

This gives 0 instead of 16;

f = check_hfouten();
$.each(rest, function(idx, val,f) { 
  //alert(idx + ': ' + val); 
  $('td.info.'+idx).children('span').addClass('fout').attr('title',val).end().parent('tr').find('input').addClass('overlayed').click(function(){$(this).removeClass('overlayed')});
    $('.tag_cloud.'+idx).addClass('reminder');
}).function(f);

感谢在理查德

推荐答案

每个()回调中的 f()

$.each(rest, function(idx, val,f) { 
    //alert(idx + ': ' + val); 
    // -Snip-
    $('.tag_cloud.'+idx).addClass('reminder');
    f();
});

这篇关于jquery后执行回调每次迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆