-3
I’m learning javascript and trying to make a program that calculates the exact day a person was born.
For this I created a date form on html and he returns me for example: 2010-06-21... In order for me to calculate the exact day of the person’s birth, I need to take it separately input:date
the day/month/year and put them in a variable. I have tried several ways and could not, can anyone help me? My code is like this:
function calcular (){
var d = document.querySelector('input#data').value
alert(d)
}
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Modelo de exercicio</title>
<link rel="stylesheet" href="estilo.css">
</head>
<body>
<header>
<h4>Descubra o dia da semana que você nasceu</h4>
</header>
<section>
<div id = 'primeiro'>
Coloque sua data de nascimento
</div>
<br>
<input type="date" name="data" id="data">
<input type="button" name = 'botao' id='botao' value="Calcular" onclick="calcular()">
<div>
.
</div>
</section>
<footer>
<p>© CursoemVideo</p>
</footer>
</body>
</html>
Welcome to [en.so]! You have posted an image of the code and/or error message. Although it sounds like a good idea, it’s not! One of the reasons is that if someone wants to answer the question, they can’t copy the code and change something inside. Click on the [Edit] link and put the code/error as text. See more about this in these links - Manual on how NOT to ask questions, Post Error Message as Picture
– Lucas
Do not use greetings or greetings, see what kind of behavior is expected from users?
– gleisin-dev