teste de Nacionalidade

HTML

JavaScript

19/02/2021

Boa tarde. Sou bem iniciante em programação e estou com dúvida neste meu código que não está funcionado. Alguém poderia me ajudar, por favor? Obrigado.
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nacionalidade</title>
<style>
body {
background-color: violet;
color: white;
font: normal 10pt Arial;
}
</style>
</head>

<body><h1>De qual país você é ?</h1>
<input type="text" name="txtvel" id="txtvel">
<input type="button" value="Verificar" onclick="resultado()">
<div id="res">


</div>
<script>
function resultado() {
var txtv = window.document.querySelector(''''''''input#txtvel'''''''')
var res = window.document.querySelector(''''''''div#res'''''''')
var p = Text(txtv.value)
res.innerHTML == `<p>Você é <strong>$</strong></p>`
if (vel == ''''''''EUA'''''''') {
res.innerHTML == `<p>Você é Americano!</p>`
res.innerHTML == `<p>Você é <strong>Americano</strong`>
}


}
</script>

</body>
</html>
Jean Sousa

Jean Sousa

Curtidas 0

Melhor post

Heraldo Araujo

Heraldo Araujo

25/02/2021

Olá, Jean...dei uma corrigida ne teu código para puder ele ser executado.


Ficou assim :


<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="ISO 8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nacionalidade</title>
<style>
body {
background-color: violet;
color: white;
font: normal 10pt Arial;
}
</style>
</head>

<body><h1>De qual país você é ?</h1>
<input type="text" name="txtvel" id="txtvel">
<input type="button" value="Verificar" onClick="resultado()" >
<div id="res">

</div>
<script>
function resultado() {

var texto = document.getElementById("txtvel").value;
texto = texto.toUpperCase(); //garantir caixa alta

document.getElementById("res").innerHTML = ""; //limpar no inicio

if ( texto == "RUSSIA") {

document.getElementById("res").innerHTML = "Você é um cidadão russo";

}

if ( texto == "EUA") {

document.getElementById("res").innerHTML = "Você é um cidadão americano";

}


}
</script>

</body>
</html>
GOSTEI 1

Mais Respostas

Jean Sousa

Jean Sousa

19/02/2021

Olá, Jean...dei uma corrigida ne teu código para puder ele ser executado.

Muito Obrigado Heraldo
Ficou assim :


<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="ISO 8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nacionalidade</title>
<style>
body {
background-color: violet;
color: white;
font: normal 10pt Arial;
}
</style>
</head>

<body><h1>De qual país você é ?</h1>
<input type="text" name="txtvel" id="txtvel">
<input type="button" value="Verificar" onClick="resultado()" >
<div id="res">

</div>
<script>
function resultado() {

var texto = document.getElementById("txtvel").value;
texto = texto.toUpperCase(); //garantir caixa alta

document.getElementById("res").innerHTML = ""; //limpar no inicio

if ( texto == "RUSSIA") {

document.getElementById("res").innerHTML = "Você é um cidadão russo";

}

if ( texto == "EUA") {

document.getElementById("res").innerHTML = "Você é um cidadão americano";

}


}
</script>

</body>
</html>
GOSTEI 0
POSTAR