开发者

reactivating or binding a hover function in jquery?

with the following three lines:

$( ".thumb" ).bind( "mousedown", function() {
        $('.thumb').not(this).unbind('mouseenter mouseleave');
    });  

i'm unbinding this hover-function:

$(".thumb").hover(
      function () {
        $(this).not('.text, .file, .video, .audio').stop().animate({"height": full}, "fast");
        $(this).css('z-index', z);
        z++;        
      },
      function () {
        $(this).stop().animate({"height": small}, "fast");
      }
    );  

i wonder how i can re-bind the exact same hover function again on mouseup? the follwoing three lines arent't working!

$( ".thumb" ).bind( "mouseup", function() {
$('.thumb').bind('mouseenter mouseleave');
});

to get what i wanna do here's a small explanation. I want to kind开发者_运维百科 of deactivate the hover function for ALL .thumbs-elements when i click on one. So all (but not this) should not have the hover function assigned while i'm clicking on an object. If i release the mouse again, the hover function should work again like before.

Is that even possible to do? thank you for your help!


Wrap it in a custom function:

function bind_hover(elements) {   
    elements.hover(
      // ...
    );   
};

and later:

$( ".thumb" ).bind( "mouseup", function() {
    bind_hover($('.thumb').not(this));
});

This

$('.thumb').bind('mouseenter mouseleave');

cannot work. You are not specifying which handlers you want to bind.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜