javascript JQuery 日期选择器不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3745360/
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
JQuery Datepicker not working
提问by Jim Jeffries
I am trying to get a date picker working and I am really struggling with my limited javascript knowledge. I have been basing this on this tutorial.
我正在尝试让日期选择器工作,但我真的很苦于我有限的 javascript 知识。我一直以此教程为基础。
I have the following code:
我有以下代码:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="scripts/date.js"></script>
<script type="text/javascript" src="scripts/jquery.datePicker.js"></script>
<script type="text/javascript" charset="utf-8">
$(function()
{
$('.date-pick').datePicker().val(new Date().asString()).trigger('change');
});
</script>
...
...
<input name="oDate" id="oDate" class="date-pick" />
Any suggestions would be very much appreciated.
任何建议将不胜感激。
回答by leora
i would suggest you take a look at the regular jquery ui datepickerto get a standard out of the box datepicker working. Start by simply using the exact code you see here and then tweak (step by step) as necessary. There are tons of example for all different use cases and good documentation
我建议你看看常规的 jquery ui datepicker以获得一个标准的开箱即用的 datepicker 工作。首先简单地使用您在此处看到的确切代码,然后根据需要进行调整(逐步)。有大量适用于所有不同用例和良好文档的示例
回答by Alpesh
I have tried below configuration and it's working fine on my local host -
我已经尝试过以下配置,它在我的本地主机上运行良好 -
Browser Tested - Mozilla Firefox version 3.6.10
浏览器测试 - Mozilla Firefox 版本 3.6.10
I have xampp package installed.
我已经安装了 xampp 包。
I am including the html file that i have used for testing -
我包括我用于测试的 html 文件 -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="date.js"></script>
<script type="text/javascript" src="jquery.datePicker.js"></script>
<LINK REL=StyleSheet HREF="datePicker.css" TYPE="text/css" MEDIA=screen>
<script type="text/javascript" charset="utf-8">
$(function()
{
$('.date-pick').datePicker().val(new Date().asString()).trigger('change');
//$('.date-pick').dpSetEndDate('01/01/2010');
});
</script>
</head>
<body>
<input name="oDate" id="oDate" class="date-pick" />
</body>
</html>
回答by petsagouris
I hope you have an inputtag like so in your HTML body:
我希望你input的 HTML 中有一个这样的标签body:
<input name="date" id="date" class="date-pick" />
回答by ssug89
Please check if browser java script is turned off
请检查浏览器java脚本是否关闭

