开发者

Bind & Unbind... how to bind again when this function finished?

http://jsfiddle.net/3NRsd/

var foo =  $("div").bind("click", function() {
    $("div").animate({"height" : "500开发者_如何学Pythonpx"}, 2000);
    $("div").animate({"height" : "50px"}, 2000);
    $("div").unbind();
    });


You could do:

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

DEMO


You can rebind it in a callback from the animate function:

http://jsfiddle.net/3NRsd/8/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜