javascript - jquery:当 'hover' 在 '.myBox' 上解除绑定(bind)时执行某些操作?

标签 javascript jquery unbind

在 Jquery 中是否有可能拥有它,所以当我在 .myBox 上取消绑定(bind)悬停时,它会执行某些操作?我想将其添加到我正在制作的第一个插件中,不确定如何?

当取消绑定(bind)悬停在特定元素上时,我总是希望完成一些特定的事情,例如 css('cursor', 'default') 和其他一些事情。有没有一种方法可以在某些内容解除绑定(bind)时触发某些内容,而不必在声明解除绑定(bind)时执行这些操作?

最佳答案

执行此操作的唯一方法是扩展 unbind 函数本身:

(function ($) {

   var unbind = jQuery.fn.unbind;

   jQuery.fn.unbind = function(type, func) {
       var matchedElements = this.filter('#matchedElement1,#matchedElement2');
       if (matchedElements.length && typeof type == "string" && type == "mouseover") {
          // Blah Blah, whatever you wanted to do (do it to matchedElements rather than this).
       }

       return unbind.apply(this, arguments); // Call the actual unbind handler.
   };

   /* The rest of your plugin */

}(jQuery));

关于javascript - jquery:当 'hover' 在 '.myBox' 上解除绑定(bind)时执行某些操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5457935/

相关文章:

javascript - 将 JSON 数据链接到 d3 中的 g 元素

javascript - typescript - 在没有构造函数的情况下扩展类定义

javascript - Bootstrap datepicker 数据与 Angular 4 的绑定(bind)不起作用

javascript - 类似 Jinja 的 JS 模板语言

javascript - jquery:绑定(bind)多个事件,然后取消绑定(bind)其中的几个?这是正确的吗?

javascript - 使用Chrome扩展解除绑定(bind)点击事件?

javascript - 如何使用vuejs切换显示

javascript - 在 JavaScript 中,变量 i 没有传递给循环中的函数

jquery - 无法在 django 表单中使用 jquery 更新 choiceField

jquery - 移动 safari/chrome 上的图像错误加载占位符图像问题