gpt4 book ai didi

javascript - Amsul DatePicker - 如何在选择选项中加载年数?

转载 作者:太空宇宙 更新时间:2023-11-04 06:15:52 24 4
gpt4 key购买 nike

我正在使用 Amsul DatePicker:https://amsul.ca/pickadate.js/date/#selectors而且我无法找出如何在年份下拉列表中加载所需年数。默认情况下,它会在当年的前半年和当年的后半年到来。

所以我想要实现的是我想加载从当前年份回溯 150 年。

寻求帮助。

谢谢

$('.datepicker').pickadate({
selectYears: 100,
selectMonths: true,
min: true
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://hateable-tests.000webhostapp.com/classic.css" rel="stylesheet">
<link href="https://hateable-tests.000webhostapp.com/classic.date.css" rel="stylesheet">
<link href="https://hateable-tests.000webhostapp.com/classic.time.css" rel="stylesheet">
<script src="https://hateable-tests.000webhostapp.com/picker.js"></script>
<script src="https://hateable-tests.000webhostapp.com/legacy.js"></script>
<script src="https://hateable-tests.000webhostapp.com/picker.date.js"></script>
<script src="https://hateable-tests.000webhostapp.com/picker.time.js"></script>

<input name="dob" type="text" class="form-control account-field-input datepicker">

最佳答案

更改您的初始设置以包括 minmax 日期。

var maxDate = new Date();
var minDate = new Date();
minDate.setFullYear( minDate.getFullYear() - 150 );

$('.datepicker').pickadate({
min: minDate,
max: maxDate,
selectYears: 150,
selectMonths: true
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://hateable-tests.000webhostapp.com/classic.css" rel="stylesheet">
<link href="https://hateable-tests.000webhostapp.com/classic.date.css" rel="stylesheet">
<link href="https://hateable-tests.000webhostapp.com/classic.time.css" rel="stylesheet">
<script src="https://hateable-tests.000webhostapp.com/picker.js"></script>
<script src="https://hateable-tests.000webhostapp.com/legacy.js"></script>
<script src="https://hateable-tests.000webhostapp.com/picker.date.js"></script>
<script src="https://hateable-tests.000webhostapp.com/picker.time.js"></script>

<input name="dob" type="text" class="form-control account-field-input datepicker">

关于javascript - Amsul DatePicker - 如何在选择选项中加载年数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55968879/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com