【问题标题】:jQuery datepicker not workingjQuery 日期选择器不工作
【发布时间】:2016-01-26 20:01:56
【问题描述】:

我查看了所有类似名称的问题,这让我更加想知道为什么这不起作用。

我包括:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>

我的 script.js 中有以下内容:

$(document).ready(function() {
  $( "#dateField" ).datepicker();
});

这是 HTML:

<form>
<input type="text" size="50" ng-model="thisItem.title" /><br/><br/>
<textarea cols="50" rows="10" ng-model="thisItem.details"></textarea>
<br/><br/>
<input type="text" ng-model="thisItem.due" id="dateField" /><br/><br/>
</form>

当我点击dateField 输入时,什么也没有显示。

我忘记了什么?

【问题讨论】:

  • 您遇到什么错误?你还包括 jQuery 和 UI CSS 吗?
  • jquery 文件本身呢?它是否包含在 jquery ui 文件之前?
  • 没有错误。它只是没有做任何事情。我在 UI 之前包含了 jquery 文件和 UI CSS。唯一出现的错误是关于未找到的 favico,它来来去去,这没有意义,因为我从未要求它包含一个。除此之外,没有错误。
  • 你能用 jsFiddle 重现这个问题吗?
  • 你确实也加载了 CSS,我想

标签: jquery datepicker


【解决方案1】:

试试这个

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet"      href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
 $(function() {
    $( "#datepicker" ).datepicker();
});
 </script>
</head>
 <body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>

【讨论】:

  • 这实际上是我最初的基础。还是不行。
  • 您能详细介绍一下您的测试环境吗?您使用的是哪个浏览器?你使用的是纯 html 吗?
  • 这是在 Chrome 中(我可以在 jQuery 网站上看到它),不,在某些时候涉及到 Angular
  • 谢谢,但我并没有在 Angular 中使用 datepicker 部分。我碰巧也有 Angular 正在进行。我正在加载/使用独立于 Angular 的 jquery/datepicker
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-29
  • 1970-01-01
  • 2012-09-22
相关资源
最近更新 更多