javascript - jQuery 悬停动画仅在不同类之间

标签 javascript jquery html

我有this代码

HTML:

<div class="random">div 1</div>
<div class="random animation">div 2</div>
<div class="random animation">div 3</div>

<div class="random animated">Fade</div>

JS:

jQuery( document ).ready( function( $ ) {

$( ".animation" ).hover(

    function() {
        $( ".animated" ).hide( 500 );


    }, function() {
        $( ".animated" ).show( 500 );


    }
);

});

如何在div 2和div 3之间切换时不触发动画? 我想这很简单...

<小时/>

stop()有一个问题,实际上我正在使用

addClass( "uk-animation-reverse uk-animation-scale-down" ) 

removeClass( "uk-animation-reverse" ) 

控制动画=/是这样工作还是有其他想法?

最佳答案

简单stop动画(如果它在每个元素的悬停事件之间运行):

jQuery( document ).ready( function( $ ) {
  $(".animation" ).hover(
    function() {
      $( ".animated" ).stop().hide( 500 );
    }, function() {
      $( ".animated" ).stop().show( 500 );
    }
  );
});

Fiddle

关于javascript - jQuery 悬停动画仅在不同类之间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29808887/

相关文章:

javascript - 如何在 Perl 中使用 WWW::Scripter 模块显式清除 cookie?

javascript - 一种在firefox的urlbar中观察url,每次变化时获取事件的方法

javascript - 直接为原型(prototype)的属性赋值与.extend 的区别

javascript - 如何使用 jQuery 旋转 HTML 内容以使顺序每 30 秒更改一次?

html - 应用程序缓存错误事件 : Manifest fetch failed (404)

jquery - 在滚动条上弹跳一次滚动条

javascript - 在 JSDoc 中记录开放式参数函数的正确方法

javascript - 无法为我的 react 应用程序禁用实时重新加载 webpack 开发服务器

javascript - 多个时间间隔的jquery图像 slider

javascript - 计算 HTML 表格中的百分比 - jQuery