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