javascript 类型错误:getDay 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21675631/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 21:27:37 来源:igfitidea点击:
TypeError: getDay is not a function
提问by Chintan
I have used getDay method in my JavaScript code, but I am getting getDay is not a function.
我在 JavaScript 代码中使用了 getDay 方法,但我发现 getDay 不是一个函数。
Below is my js code,
下面是我的js代码,
var lsDate = document.getElementById('<%=txtAddDate.ClientID %>');
var loIsDate = new Date(lsDate.value);
if (loIsDate != 'Invalid Date') {
alert(lsDate.getDay());
}
Here is my jsfiddle code : http://jsfiddle.net/C4hVd/
这是我的 jsfiddle 代码:http: //jsfiddle.net/C4hVd/
Am I missing something?
我错过了什么吗?
回答by zzlalani
回答by Prashobh
var loIsDate = new Date(lsDate.value);
to
到
var loIsDate = new Date(lsDate);
and
和
alert(lsDate.getDay());
to
到
alert(loIsDate.getDay());