首页 > 解决方案 > jQuery日期选择器没有输出

问题描述

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

$("#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">

标签: jquerydatepicker

解决方案


看起来您错过了 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>


推荐阅读