Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<script>
function calculate(){
var yearNow = 2010;
var yearBorn = document.getElementById('year').value;
document.getElementById('result').innerHTML =( yearNow-parseInt(yearBorn) ) + ' години';
}
</script>
Година на раждане: <input type="text" id="year">
<input type="button" onClick="calculate();" value="Изчисли">
Възраст: <span id="result"></span>
F1r3Fl3x каза:Така?
Код:<script> function calculate(){ var yearNow = 2010; var yearBorn = document.getElementById('year').value; document.getElementById('result').innerHTML =( yearNow-parseInt(yearBorn) ) + ' години'; } </script> Година на раждане: <input type="text" id="year"> <input type="button" onClick="calculate();" value="Изчисли"> Възраст: <span id="result"></span>
<html>
<head>
<script>
function age(){
now = new Date();
day = 23;
month = 09;
year = 1993;
born = new Date(month+'.'+day+'.'+year);
years = Math.floor((now.getTime() - born.getTime()) / (365 * 24 * 60 * 60 * 1000));
alert(years)
}
</script>
</head>
<body onload="age()">
</body>
</html>
Liberate каза:примерноКод:<html> <head> <script> function age(){ now = new Date(); day = 23; month = 09; year = 1993; born = new Date(month+'.'+day+'.'+year); years = Math.floor((now.getTime() - born.getTime()) / (365 * 24 * 60 * 60 * 1000)); alert(years) } </script> </head> <body onload="age()"> </body> </html>