how can i add multiple conditions in JavaScript? i dont want to check with the && i want to know if its a way like elseif or idk to check all conditions if the first one is false then go to another and if that too is false go to else. In my example if i write 'blank' in the text field it will show me nothing. The code wont work but if i delete the code from the elseif(*) part is going to work just fine. Why my elseif doesnt work? I tried to write something different then "blank" to check my elseif condition too but idk why it doesn't work. This is my code:
function Test() {
var test = document.getElementById('name').value;
var para = document.getElementById('hidden');
if (test == "blank") {
document.write(test.length);
}
( * ) - > elseif(test = "Cristian") {
para.innerHTML = "this is first para";
} < -( * )
else {
para.innerHTML = "this is second para";
para.style.font = "italic bold 20px arial,serif";
}
}
<p id="hidden">Surprise!</p>
<input type="text" id="name" />
<input type="button" onclick="Test()" value="press me" ;
Aucun commentaire:
Enregistrer un commentaire