-1
如何从文本中获得价值,当我在按钮点击我的函数可以使用文本框的值 这个程序是计算年龄获取价值
function getDate(birth){
var now = new Date();
var currentYear = now.getFullYear();
var currentMonth = now.getMonth();
var currentDay = now.getDate();
var birthYear = birth.getFullYear();
var birthMonth = birth.getMonth();
var birthDay = birth.getDate();
var age = currentYear - birthYear;
var age_month = currentMonth - birthmonth;
}
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="javascript.js"></script>
</head>
<body>
<form>
<input type="text"/>
<input type="button" value="Calc" onclick="getAge()"/>
</form>
</body>
</html>
我真的不明白你在问什么,getAge函数在哪里? –