【问题标题】:How can I modify my plugin to work with hoverIntent if it is available?如果可用,我如何修改我的插件以使用 hoverIntent?
【发布时间】:2011-04-28 04:34:17
【问题描述】:

我有一个使用 hover() 的插件,但如果可用,它应该使用 hoverIntent()

我将如何以最小的麻烦做到这一点?

【问题讨论】:

    标签: jquery hoverintent


    【解决方案1】:

    这将检测是否已包含 hoverIntent,并在这种情况下将 hover 方法修改为 hoverIntent

    var bindMethod = $.isFunction(jQuery().hoverIntent) ? 'hoverIntent' : 'hover';
    
    element[bindMethod](
    function() {
      // Mouse over
    },
    function() {
      // Mouse out
    });
    

    然后您可以在您的插件上留言...

    【讨论】:

      猜你喜欢
      • 2013-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-31
      • 1970-01-01
      • 2018-12-08
      • 2022-01-14
      • 1970-01-01
      相关资源
      最近更新 更多