开发者

jquery: do something when 'hover' is unbinded on '.myBox'?

开发者 https://www.devze.com 2023-02-20 01:17 出处:网络
is it possible in Jquery to have it so, when i unbind hover, on .myBox, it does something? I wanted to add that into the first plugin i\'m making, wasn\'t sure how?

is it possible in Jquery to have it so, when i unbind hover, on .myBox, it does something? I wanted to add that into the first plugin i'm making, wasn't sure how?

there's specific t开发者_如何转开发hings I want to always be done when unbinding hover on specific elements, like css('cursor', 'default') and a few other things. Is there a way to have stuff triggered when something is unbound, without having to do that stuff when declaring the unbind?


The only way to do this would be to extend the unbind function itself:

(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));
0

精彩评论

暂无评论...
验证码 换一张
取 消