Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我每个都创建了一个循环,请查看以下示例:
$('.foo').each(function(i){ //do stuff });
当此循环结束时,是否有可能运行函数?在 docs 或 Google 上找不到它。
我可以在没有这种解决方案的情况下让它工作,但搜索和使用最简单的方法总是好的。
马蒂莱恩
按照要求..
这取决于您在每个循环中调用的内容。您需要为那些(或至少您希望最后完成的那个)添加一个回调
这将在循环结束时执行。
$('.foo').each(function(i){ //do stuff }); $('.foo').//whatever you want to do.