带有mouseover的jQuery仅在悬停时有效

时间:2018-07-04 15:55:52

标签: javascript jquery html hover

jquery鼠标悬停时遇到一些困难。

我只想让鼠标悬停在图像上方而不是鼠标离开时产生失真效果。我使用mgGlitch的效果,并使用jquery的悬停。感谢您的帮助!

JQUERY

$(".glitch-img").hover(function() {
    $( ".glitch-img" ).mgGlitch({
      // set 'true' to stop the plugin
              destroy : false,
      // set 'false' to stop glitching
      glitch: true,
      // set 'false' to stop scaling
      scale: true,
      // set 'false' to stop glitch blending
      blend : true,
      // select blend mode type
      blendModeType : 'hue',
      // set min time for glitch 1 elem
      glitch1TimeMin : 200,
      // set max time for glitch 1 elem
      glitch1TimeMax : 400,
      // set min time for glitch 2 elem
      glitch2TimeMin : 10,
      // set max time for glitch 2 elem
      glitch2TimeMax : 100,
    }),


    // .mouseout(function() {
    //      $(".glitch-img").myGlitch({
    //          // set 'true' to stop the plugin
    //                destroy : false,
    //          // set 'false' to stop glitching
    //          glitch: false,
    //          // set 'false' to stop scaling
    //          scale: false,
    //          // set 'false' to stop glitch blending
    //          blend : false,
    // })

});

1 个答案:

答案 0 :(得分:0)

来自JQuery Docs

  

.hover()方法为mouseenter和mouseleave事件绑定处理程序。

您要做的是将事件绑定到mouseover()函数。 Reference