0
如何有效地從dob獲得年齡?你會給我更多的信息嗎? 如何從JavaScript中獲得DOB的年齡
function myFunction(){
\t \t \t var d = new Date();
\t \t \t var year = new Date(document.getElementById('dob').value); \t \t \t
\t \t \t var age = d.getFullYear() - year.getFullYear();
\t \t \t document.getElementById('age').value = age; \t \t \t
\t \t }
<input type="date" id="dob" placeholder="Date of birthday" onchange="myFunction()"><br/>
\t \t \t <input type="text" id="age">
可能重複://計算器.COM /問題/ 4060004 /計算,年齡在JavaScript的) –