<!DOCTYPE html>
<!--
计算性别,年龄,生日
-->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
li{
list-style: none;
}
</style>
</head>
<body>
<input type="text" value="142723199307182512" id="ids">
<input type="button" value="计算" id="btn">
<ul>
<li><span id="sex">性别:</span></li>
<li><span id="age">年龄:</span></li>
<li><span id="birth">生日:</span></li>
</ul>
<script >
var btn = document.getElementById("btn");
btn.onclick = function () {
alert(0);
var ids = document.getElementById("ids").value;
if (parseInt(ids[ids.length - 2] % 2 == 0)) {
document.getElementById("sex").innerHTML="女";
}else{
document.getElementById("sex").innerHTML="男";
}
var birth = ids.slice(6,6+8);
document.getElementById("birth").innerHTML=birth;
var year = ids.slice(6,6+4);
var thisyear = new Date().getFullYear();
document.getElementById("age").innerHTML = thisyear-year;
}
</script>
</body>
</html>