3 回答

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊
只需使用并操作它會(huì)幫助您檢查 2 個(gè)條件
function myfun(){
//var yofad = document.getElementById('age').value;
var yoad;
var year = 2014 ;
if( year >= 2014 && year <2019){
yoad = "Your certicate is ready go to school portal";
}else if (year == 2019){
yoad = "Your certificate is in progress";
} else {
yoad = "cert not found";
}
document.getElementById('cc').innerHTML=yoad
}

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊
將您的第一個(gè)條件限制為小于 2019,否則對(duì)于 2019、2020 和其他更大的值也將成立。改為if(year >= 14)_if(year >= 14 && year <2019)
function myfun(){
var year = document.getElementById('age').value;
var yoad;
if( year >= 2014 && year < 2019){
yoad = "Your certicate is ready go to school portal";
} else if (year == 2019){
yoad = "Your certificate is in progress";
} else {
yoad = "cert not found";
}
document.getElementById('cc').innerHTML=yoad
}
<h6>Enter your year of admission to know if your certificate is ready</h6>
<input id="age">
<button onclick="myfun()">enter</button>
<p id="xc"></p>
<p id="cc"></p>

TA貢獻(xiàn)1860條經(jīng)驗(yàn) 獲得超8個(gè)贊
function myfun(){
document.getElementById('cc').innerHTML = "";
const value = document.getElementById('age').value;
if (!value) return;
const year = parseInt(value);
let yoad;
if (year > 2019) {
yoad = "certicate not read";
} else if (year >= 2014 && year <= 2019) {
yoad = "Your certicate is ready go to school portal";
} else {
yoad = "cert not found";
}
document.getElementById('cc').innerHTML = yoad
}
<h6>Enter your year of admission to know if your certificate is ready</h6>
<input id="age">
<button onclick="myfun()">enter</button>
<p id="xc"></p>
<p id="cc"></p>
也許你需要這樣的東西!
添加回答
舉報(bào)