有人可以建议一种方法来比较使用JavaScript大于,小于和过去的两个日期的值吗?值将来自文本框。
3 回答

慕桂英3389331
TA贡献2036条经验 获得超8个赞
比较<和>正常情况一样,但任何涉及的=都应该使用+前缀。像这样:
var x = new Date('2013-05-23');
var y = new Date('2013-05-23');
// less than, greater than is fine:
x < y; => false
x > y; => false
x === y; => false, oops!
// anything involving '=' should use the '+' prefix
// it will then compare the dates' millisecond values
+x <= +y; => true
+x >= +y; => true
+x === +y; => true
希望这可以帮助!
添加回答
举报
0/150
提交
取消