如何在输入Bootstrap Datepicker中只显示几年? [英] How display only years in input Bootstrap Datepicker?

查看:149
本文介绍了如何在输入Bootstrap Datepicker中只显示几年?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码仅显示年份:

I am using the following code to display only the years:

$("#datepicker").datepicker( {viewMode: "years", minViewMode: "years"});

但输入格式为dd / mm / yyyy code>

but input appears in the format "dd/mm/yyyy"

如何解决这个问题,因为我没有格式yyyy

How can I solve this since I do not have the format "yyyy"?

推荐答案

尝试这个 - 演示

Try this - DEMO

$("#datepicker").datepicker( {
    format: " yyyy", // Notice the Extra space at the beginning
    viewMode: "years", 
    minViewMode: "years"
});

这篇关于如何在输入Bootstrap Datepicker中只显示几年?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆