绑定与取消绑定…该功能完成后如何再次绑定?

问题描述

| http://jsfiddle.net/3NRsd/
var foo =  $(\"div\").bind(\"click\",function() {
    $(\"div\").animate({\"height\" : \"500px\"},2000);
    $(\"div\").animate({\"height\" : \"50px\"},2000);
    $(\"div\").unbind();
    });
    

解决方法

        您可以这样做:
function handler() {
    $(this)
     .unbind()
     .animate({\"height\" : \"500px\"},2000);
     .animate({\"height\" : \"50px\"},2000,function(){
         $(this).click(handler); // <- gets called once the animation finishes
     });
}

$(\'div\').click(handler);
演示     ,        您可以通过animate函数在回调中重新绑定它: http://jsfiddle.net/3NRsd/8/