<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" charset="utf-8">
function btu_onclick(){
var d1 = document.getElementById("date1").value;
//alert(d1);
var d2 = document.getElementById("date2").value;
var cha = Date.parse(d1) - Date.parse(d2);
//alert(cha);
if(cha < 0){
cha = cha * -1;
}
cha = cha / (1000*60*60*24);
alert("相差" + cha + "天");
}
</script>
</head>
<body>
<form>
<input type="date" id = "date1" />
<input type="date" id = "date2" />
<input type="button" name="btu" value="计算" onclick="btu_onclick()">
</form>
</body>
</html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" charset="utf-8">
function btu_onclick(){
var d1 = document.getElementById("date1").value;
//alert(d1);
var d2 = document.getElementById("date2").value;
var cha = Date.parse(d1) - Date.parse(d2);
//alert(cha);
if(cha < 0){
cha = cha * -1;
}
cha = cha / (1000*60*60*24);
alert("相差" + cha + "天");
}
</script>
</head>
<body>
<form>
<input type="date" id = "date1" />
<input type="date" id = "date2" />
<input type="button" name="btu" value="计算" onclick="btu_onclick()">
</form>
</body>
</html>