I have my code:
$(this).attr("disabled","disabled");
$(this).animate({'opacity':'0.6'}, 200);
$(this).animate({'opacity':'1'}, 200);
$(this).attr("disabled","");
I want that the input would be disabled when the keypress
'ed and it would be enabled only then, when the animation would be executed.
How can I do that?
Edit: I just realized I could do like that: $(this).delay(200).attr("disabled","");
. Is it good practice?
Use a callback:
$(this).animate({'opacity':'0.6'}, 200, function() {
// Animation complete.
});
Not good practice to delay events, it is better to use an animation callback function. For example:
$(this).animate({'opacity':'1'}, 200, function(){
$(this).attr("disabled","");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With