0

I've checked this code: https://stackoverflow.com/a/21337187/7425712 and it works a great, but I think how I can get age without submit. I just want that

<p>You are 29</p>

printed and nothing else.

function submitBday() {
   var Q4A = "Your birthday is: ";
   var Bdate = document.getElementById('bday').value;
   var Bday = +new Date(Bdate);
   Q4A += Bdate + ". You are " + ~~ ((Date.now() - Bday) / (31557600000));
   var theBday = document.getElementById('resultBday');
   theBday.innerHTML = Q4A;
}

I've tried something like this, but I'm not good with js.

 var Bdate = new Date("01/30/1989");

thanks! :)

Penalse
  • 175
  • 1
  • 1
  • 8

0 Answers0