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));
精彩评论