在 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/