Created
March 25, 2012 15:03
-
-
Save jacobbednarz/2196919 to your computer and use it in GitHub Desktop.
Dynamically update age
This file contains 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> | |
<head> | |
<meta charset=utf-8 /> | |
<title></title> | |
</head> | |
<body> | |
<p>My age is: <span id="age"></span></p> | |
</body> | |
<script> | |
var age_span = document.getElementById('age'); | |
var dob = 1991; | |
var current_year = new Date().getFullYear(); | |
age_span.innerHTML = current_year - dob; | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment