条件に変数を追加しようとしていて、if()条件で代入しようとしましたが、期待通りに機能しません。jQuery複数の条件を1つの変数
しようとした可能性:
1)
conditionCheck = (getMonth == undefined || getMonth == "" || getMonth == null
|| getDay == undefined || getDay == "" || getDay == null
|| getYear == undefined || getYear == "" || getYear == null)
2)
conditionCheck = getMonth == undefined || getMonth == "" || getMonth == null
|| getDay == undefined || getDay == "" || getDay == null
|| getYear == undefined || getYear == "" || getYear == null
3)
conditionCheck = "getMonth == undefined || getMonth == "" || getMonth == null
|| getDay == undefined || getDay == "" || getDay == null
|| getYear == undefined || getYear == "" || getYear == null"
しかし、私は、その後の状態でその作業であるとして追加した場合良い。
このようです。 - >
if (getMonth == undefined || getMonth == "" || getMonth == null
|| getDay == undefined || getDay == "" || getDay == null
|| getYear == undefined || getYear == "" || getYear == null) {
} else {
ageCalculation();
}
任意のアイデア/提案ですか?
編集:
function ageCalculation() {
getDate = getYear + "-" + getMonth + "-" + getDay;
dob = new Date(getDate);
today = new Date();
age = (today - dob)/(365.25 * 24 * 60 * 60 * 1000);
if (age < 3 || age == 3 || age > 3 && age < 3.00452422294471007) {
$('.greater-msg, .less-then-msg').remove();
$(contentParent).find('.fieldset-wrapper').after('<div class="less-then-msg">Disclaimer: In compliance with EO51, cannot directly engage with mothers with children aged 0 to 3 years old. All content that you will receive via email will only be regarding your pregnancy. </div>');
} else if (age > 3) {
$('.greater-msg, .less-then-msg').remove();
$(contentParent).find('.fieldset-wrapper').after('<div class="greater-msg">You can also visit to know how you can keep giving your child the 360 advantage.</div>');
}
if (age <= -1 || age <= -0 || age == 0 || age == -0) {
$('.greater-msg, .less-then-msg').remove();
}
}
感謝!!
didnotの仕事はどういう意味ですか? conditionCheck変数 –
であなたは何をしましたか? また、3番目の文字列は 'true'と評価される文字列です。 –
データ型に応じてvariablesadd stringまたはnumを追加すると良いです。変数は条件のチェックには使用できません。ただし、変数の前にletを追加したい場合は – mayur