I need to loop through each div .row to add or remove a flip class that has a CSS3 3D transform effect.

我需要遍历每个div .row来添加或删除具有CSS3 3D变换效果的翻转类。

When I apply this add/remove class to each ".row" with jquery each(), all the divs get the class ".flip" added or removed at the exact same time. I need this to be delayed so it looks like a domino effect.

当我使用jquery each()将每个“.row”应用此添加/删除类时,所有div都会在同一时间添加或删除类“.flip”。我需要这个延迟,所以它看起来像多米诺骨牌效应。

Any idea how I can get this working? Or how to add / remove the flip class one by one??

知道如何让这个工作吗?或者如何逐个添加/删除翻转类?

This is what I've found but it is not working:

这是我发现但它不起作用:

  $('.row').each(function(i){
    if($(this).hasClass('flip')){
      $(this).delay(i*500).removeClass('flip');
    }else{
      $(this).delay(i*500).addClass('flip');
    }
  });

3 个解决方案

#1


19

The jQuery delay() method only delays the next pieces in the queue of strung together methods using $(obj).delay(500).addClass('flip'); It doesn't delay all subsequent lines of code. (check out the first example and how the code runs its animations side-by-side)

jQuery delay()方法只使用$(obj).delay(500).addClass('flip')来延迟串联方法队列中的下一个部分。它不会延迟所有后续代码行。 (查看第一个示例以及代码如何并行运行其动画)

Try using setTimeout() instead.

请尝试使用setTimeout()。

$('.row').each(function(i){
  var row = $(this);
  setTimeout(function() {
    row.toggleClass('flip');
  }, 500*i);
});​

Fiddle

小提琴

更多相关文章

  1. js限制文本框只能输入数字方法
  2. html 页面内锚点定位及跳转方法总结
  3. 是否有更快的方法来遍历HTMLDocument中的每一个元素呢?
  4. Jquery-如何使用prop方法更改backgroundColor?
  5. 关于 客户端发现响应内容类型为“text/html; charset=utf-8”,但
  6. Server.Htmlencode用于文本域显示带的html代码
  7. IOS学习之WebView加载本地HTML代码或网络资源
  8. HTML5 Canvas 绘图方法整理 【十五、Canvas页面交互: 鼠标事件 】
  9. html5 css3 背景视频循环播放代码

随机推荐

  1. Android中自定义DatePicker
  2. Anfdroid网络编程方法
  3. 打开URL启动android默认浏览器,启动指定浏
  4. Android查看包名和获取包名
  5. android中进度条控件
  6. Android学习札记17:ImageView中的setImage
  7. 2011.10.18——— android 自定义Animati
  8. Android中如何自己制作su
  9. Android休眠唤醒机制简介(二)
  10. JS判断客户端类型(ipad,iphone,android)