如何有效地从dob中获得年龄?你能给我更多信息吗?
function myFunction(){
var d = new Date();
var year = new Date(document.getElementById('dob').value);
var age = d.getFullYear() - year.getFullYear();
document.getElementById('age').value = age;
}
<input type="date" id="dob" placeholder="Date of birthday" onchange="myFunction()"><br/>
<input type="text" id="age">