使用JavaScript在internet explorer中比较日期
我有一个比较两个日期的函数。如果一个大于另一个,则执行该功能的其余部分。使用JavaScript在internet explorer中比较日期,javascript,internet-explorer,Javascript,Internet Explorer,我有一个比较两个日期的函数。如果一个大于另一个,则执行该功能的其余部分。detDate变量的格式为yyyy-mm-dd。这在Firefox和Chrome中运行良好,但在InternetExplorer中它只执行if语句的“else”部分 有没有关于原因和如何解决的建议 $(document).on('click','#confirm',function(){ var now = new Date(); now.setHours(0,0,0,0);
detDate
变量的格式为yyyy-mm-dd。这在Firefox和Chrome中运行良好,但在InternetExplorer中它只执行if语句的“else”部分
有没有关于原因和如何解决的建议
$(document).on('click','#confirm',function(){
var now = new Date();
now.setHours(0,0,0,0);
var detDate=$("#detDate").val();
var compareDate = new Date(Date.parse(detDate.replace(/-/g,', ')));
if (detDate !== "") {
if (compareDate>=now) {
$.ajax({
type:"post",
url:"ajax/detention.php",
data:"detDate="+detDate,
success:function(response){
$("#comments3").html(response);
}
});
}else {
alert("You cannot select a date that has already passed!");
}
} else {
alert("You must fill out all the empty information!");
}
});
尝试将IE浏览器中的语言首选项设置为所需格式:Internet选项>常规选项卡,“语言”按钮按顺序列出语言编码首选项。
如果有效,请尝试在If语句中设置IE默认格式,在新的var中再次解析它,并在If语句中为其添加OR。尝试将IE浏览器中的语言首选项设置为所需格式:Internet选项>常规选项卡,“语言”按钮按顺序列出您的语言编码首选项。
如果有效的话,尝试在if语句中设置IE默认格式在新的var中再次解析它,并在if语句中为其添加OR。您使用的IE版本是什么,jQuery版本是什么?Internet Explorer是什么?@Lauromine jQuery 1.11.3和最新的Internet Explorer。您是否尝试在if中使用
控制台。记录一些内容陈述是否显示?@Lauromine在if语句中不显示任何内容,即直接跳过它。您正在使用哪个版本的IE以及哪个版本的jQuery?什么是Internet Explorer
?@Lauromine jQuery 1.11.3和最新的Internet Explorer。您是否尝试在if语句中添加控制台.log
内容?是否显示?@Lauromine if语句中没有显示任何内容(只是跳过它)。