twitter-bootstrap jquery bootstrap datepicker 只有月份和日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21824696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jquery bootstrap datepicker only month and day
提问by Gia Nebieridze
i have example
我有例子
http://jsfiddle.net/rAdV6/20/?
http://jsfiddle.net/rAdV6/20/?
in jqueryui datepicker
在 jqueryui 日期选择器中
third demo example
第三个演示示例
where is only month and date.
哪里只有月份和日期。
i want this on bootstrap datepicker.
我想要这个在引导日期选择器上。
<http://www.eyecon.ro/bootstrap-datepicker/>?
回答by user3736897
The only workaround that I have made for this is to remove the year from the date title before the datepicker show. Below is the code I used to initialize the datepicker:
我为此所做的唯一解决方法是在日期选择器显示之前从日期标题中删除年份。下面是我用来初始化日期选择器的代码:
$(".datepicker").datepicker({
format : 'MM dd',
}).on('show', function() {
// remove the year from the date title before the datepicker show
var dateText = $(".datepicker-days .datepicker-switch").text();
var dateTitle = dateText.substr(0, dateText.length - 5);
$(".datepicker-days .datepicker-switch").text(dateTitle);
});
回答by Mahesa M. Elba
This is what works for me. Using jQuery split function.
这对我有用。使用 jQuery 拆分功能。
$(".datepicker").datepicker({
format : 'MM dd',
}).on('show', function() {
// remove the year from the date title before the datepicker show
var dateText = $(".datepicker-days .datepicker-switch").text().split(" ");
var dateTitle = dateText[0];
$(".datepicker-days .datepicker-switch").text(dateTitle);
$(".datepicker-months .datepicker-switch").css({"visibility":"hidden"});
});
回答by Rafi
In Jquery datepicker you can do something like this :
在 Jquery datepicker 中,您可以执行以下操作:
$(".daypicker").datepicker( {
changeYear: false,
dateFormat: 'MM-dd',
}).focus(function () {
$(".ui-datepicker-year").hide();
});
It wont affect to other datepickers in same page.
它不会影响同一页面中的其他日期选择器。
回答by Nairo Granados
Use this:
用这个:
format: "dd/mm",
weekStart: 1,
startView: 1,
maxViewMode: 1,
autoclose: true
回答by JuniorCoder
The bootstrap datepicker module is a third party tool which you need to download, install and reference from your code.
bootstrap datepicker 模块是第三方工具,您需要从代码中下载、安装和引用。
Download the javascript library from http://www.eyecon.ro/bootstrap-datepicker/.
从http://www.eyecon.ro/bootstrap-datepicker/下载 javascript 库。
All you need to do is add the following line of code and then it works.
您需要做的就是添加以下代码行,然后它就可以工作了。
$('.datepicker').datepicker({
format: "mm/dd"
})`

