2 つの要素を検証しようとしています。
GUI の場合、どちらかが空の場合、そのテキスト ボックスの色をアニメーション化します。
問題は、関数が両方がアニメーション化するのを待たないことです。
最善のアプローチは何ですか?
、を試しまし$.when
た$.promise
。うまくいかないようですか?
添加:
必要に応じて、2 つのアニメーションを表示したいと考えています。アニメーションがすべてまたはまったく完了したら、次のコマンドを実行します。
if (ChargeID.val() != '' && Quantity.val() != '') {
test = true;
}
else {
alert('I think you forgot something');
test = false;
}
return test;
ありがとう!
function TestValid(button) {
var ChargeID = $(button).parent().parent().find('input[type=hidden]').eq(1);
var Quantity = $(button).parent().parent().find('input[name=Quantity]').eq(0);
var test = true;
if (ChargeID.val() == '') {
ChargeID.animate({ "background-color": "#D2F0C9" }, "fast", function () { ChargeID.animate({ "background-color": "#ffffff" }, "fast") })
}
if (Quantity.val() == '') {
Quantity.animate({ "background-color": "#D2F0C9" }, "fast", function () { Quantity.animate({ "background-color": "#ffffff" }, "fast") })
}
if (ChargeID.val() != '' && Quantity.val() != '') {
test = true;
}
else {
alert('I think you forgot something');
test = false;
}
return test;
}