Created
December 18, 2022 16:15
-
-
Save geraldotech/8fbd9798d7ebf031e025b9e36eef7d83 to your computer and use it in GitHub Desktop.
Check Age template literal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" style="color-scheme: dark"> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Chek Age Number</title> | |
</head> | |
<body> | |
<input type="number" /> | |
<p></p> | |
<script> | |
document.querySelector("input").addEventListener("input", check); | |
const p = document.querySelector("p"); | |
function check(e) { | |
const age = e.target.value; | |
p.innerHTML = `${age >= 18 ? "maior idade" : "menor idade"}`; | |
if (age.length == 0) { | |
p.innerHTML = ""; | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment