jquery - 日期选择器默认日期
问题描述
我正在使用datepicker,在我的下拉菜单中,默认选择的年份是 1920,如果我选择输入值将具有的日期d/m/2020
。如果我从下拉列表中选择另一年,将正常工作。问题只是如果我不改变年份。setDate
也不行。
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
(function($){
$('.wcfm_datepicker').each(function() {
$(this).datepicker({
setDate: "7/11/2009",
changeMonth: true,
changeYear: true,
yearRange: "1920:2010",
});
});
})(jQuery);
</script>
解决方案
我找到了一个解决方案,它并不适合每个人,但对我来说它确实有效。您必须添加maxDate
.
$(this).datepicker({
changeMonth: true,
changeYear: true,
yearRange: "-100:-18",
maxDate: '-18y',
});
推荐阅读
- jquery - 如何在悬停时更改图像源?
- python - 为什么我的 prgram 在 Visual Studio 中没有时在 codechef ide 中显示运行时错误?
- python - 您可以将一行不同大小的行附加到数据框中吗?
- java - Spring Batch - 如何使用从 REST API 请求中收到的文件名启动作业
- keystonejs - 您可以过滤反向引用字段吗?
- r - 如何在 quanteda 中对加权 dfm 的列求和?
- windows - 如何使用带有一些多行文本的命令提示符在 Windows 中创建文件?
- acumatica - Acumatica 文档报告(发票)标题不显示页面标题中的值
- javascript - 如何在数组中找到最小值,不包括第一个索引
- javascript - jQuery 替换功能没有替换有效 HTML 中的文本?