JS中的Datepicker格式问题

时间:2014-04-21 09:31:59

标签: javascript jquery datepicker jquery-ui-datepicker

我想格式化我的日期选择器,但不起作用。什么都没发生。任何人都可以看到有什么问题吗?

<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" /> 
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script src="myJS.js" type="text/javascript"></script>

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

在我的JS文件中:

$(document).ready(function () {
    $(function () {
        $("#datepicker").datepicker({
            monthNames: ["Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"],
            dayNamesMin: ["Sön", "Mån", "Tis", "Ons", "Tors", "Fre", "Lör"],
            dateFormat: "yy-mm-dd",
            firstDay: 1,
        });
    });
});

1 个答案:

答案 0 :(得分:0)

<html>

<head>

  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

  <script>
  $(function() {
    $("#datepicker").datepicker({
 monthNames: ["Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"],
            dayNamesMin: ["Sön", "Mån", "Tis", "Ons", "Tors", "Fre", "Lör"],
            dateFormat: "yy-mm-dd",
            firstDay: 1,
        });
  });
  </script>
</head>
<body>
<input type="text" id="datepicker">


</body>
</html>

检查