为日期选择器设置默认日期格式?

编程入门 行业动态 更新时间:2024-10-26 16:31:32
本文介绍了为日期选择器设置默认日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个页面,可以跟踪各个日期.因此,我最终通过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' });

更多推荐

为日期选择器设置默认日期格式?

本文发布于:2023-11-28 14:46:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642840.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   格式   选择器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!