有没有可能在Jquery中这样做,当我在.myBox上解除hover的绑定时,它会做一些事情?我想把它添加到我正在制作的第一个插件中,不知道怎么做?
当解绑悬停在特定元素上时,我希望总是做一些特定的事情,比如css('cursor','default')和其他一些事情。有没有一种方法可以在解除绑定时触发一些东西,而不需要在声明unbind时做这些事情?
发布于 2011-03-28 19:15:34
执行此操作的唯一方法是扩展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));https://stackoverflow.com/questions/5457935
复制相似问题