I'm stuck as to why when I "focus" on the input, it doesn't display my console log message unlike if it's empty or not empty, it'll display the message. Am I using the event wrong?
(Only a portion of my code, if needed more details, please let me know)
The HTML
<input id='input' placeholder="President Name" type="text">
The JS
function message() {
var presidentInput = document.getElementById('input').value;
if (presidentInput === "") {
console.log('Please enter something in the input');
} else if (presidentInput !== "" || document.getElementById('input').onfocus){
console.log('Great job');
}
}
message();
Aucun commentaire:
Enregistrer un commentaire