我尝试获得警报,但由于某种原因,我无法获得最后一个警报来给我这段代码的差异,谁能解释为什么我没有得到结果?:
<!DOCTYPE HTML>
<html>
<body>
<input type="date" id="a">
<input type="date" id="b">
<input type="submit" id="c" onclick="getValue()">
<script>
function getValue(){
var startDate = document.getElementById("a").value;
var endDate = document.getElementById("b").value;
var parts1 = startDate.split('-');
var parts2 = endDate.split('-');
var date1 = new Date(parts1);
var date2 = new Date(parts2);
var difference = Math.Abs(parts1 - parts2);
difference = parseInt(difference / 86400000);
alert(difference);
}
</script>
</body>
</html>