我有一个页面,可以跟踪各个日期.因此,我最终通过jquery使用datepicker的时间在10-200次之间.我想将所有日期选择器的默认设置都设置为'yy-mm-dd'-但我似乎不知道如何设置该设置?
I have a page where I keep track of various dates. So I end up using datepicker through jquery anywhere from 10-200 times. I want to set the default for all cases of datepicker to the 'yy-mm-dd' - but I can't seem to figure out how to set that?
推荐答案
我最终通过jquery使用datepicker 10-200次.
I end up using datepicker through jquery anywhere from 10-200 times.
我假设您正在为每个输入分别调用datepicker(),可能是通过id.没必要.
I'm assuming you're calling datepicker() separately for each input, probably by id. There's no need for that.
将class用作输入的钩子:
<input class="my-datepicker">然后使用默认配置在具有该类的元素上调用datepicker:
Then call datepicker on elements with that class with your default configuration:
$('.my-datepicker').datepicker({ dateFormat: 'yy-mm-dd' });当您需要其他配置时,请使用/分配其他类名.
When you need a different configuration, use/assign a different class name.
您还可以使用 setDefaults (可能是您要查找的内容) :
You can also use setDefaults (probably what you're looking for):
$.datepicker.setDefaults({ dateFormat: 'yy-mm-dd' });更多推荐
为日期选择器设置默认日期格式?
发布评论