【问题标题】:jQuery date picker no outputjQuery日期选择器没有输出
【发布时间】:2021-11-04 08:18:42
【问题描述】:

代码如果我在单独的文件中运行相同的代码,它会运行。

$("#datepicker").datepicker();
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<input type="text" id="datepicker">

【问题讨论】:

  • sn-p 工作正常,所以我认为您的本地版本中一定有错误。请检查浏览器开发工具中的控制台,看看是否有可以调试的错误。

标签: jquery datepicker


【解决方案1】:

看起来您错过了 JQuery Datepicker 中的主题 css 库:

  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">

请查看运行良好的示例:

<!doctype html>
<html lang="en">
<head>
  <title>jQuery UI Datepicker- Solution</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
      $( function() {
        $( "#datepicker" ).datepicker();
      });
  </script>
</head>
<body>
 
<p>Date: <input type="text" id="datepicker"></p>
 
 
</body>
</html>

【讨论】:

  • 虽然缺少 CSS,但问题中的 sn-p 显然可以正常工作。
猜你喜欢
  • 1970-01-01
  • 2012-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-13
  • 2010-12-05
相关资源
最近更新 更多