[英]Display month and year specific datepicker in jquery
Is it possible to show a jquery inline datepicker by a specific month and year? 是否可以按特定的月份和年份显示一个jQuery内联日期选择器? Lets say I want to see the inline datepicker for Nov 2014. And it shows the complete month without selecting any date.
假设我想查看2014年11月的内联日期选择器。它显示了完整的月份而未选择任何日期。
Try to use option-dateFormat like, 尝试使用option-dateFormat之类的方法,
$(function() {
$( "#datepicker" ).datepicker({
dateFormat: 'M yy'
});
});
$(function() { $( "#datepicker" ).datepicker({ dateFormat: 'M yy' }); });
<link href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <input id="datepicker"/>
If you want to showonly month and year drop down then try the below snippet 如果您想仅显示月份和年份下拉列表,请尝试以下代码段
$(function() { $( "#datepicker" ).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'M yy', }); });
<link href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <input id="datepicker"/>
Not only One. 不只是一个。 You can even create multiple instances of datepicker each of them will be of different month.
您甚至可以创建多个datepicker实例,每个实例的月份不同。 Look here .
看这里 。
(function(){
for( var i=0; i<5; i++ ){
var dateObj = new Date();
dateObj.setMonth(i);
dateObj.setYear(dateObj.getFullYear());
var dp = $('<div id="calendar' + i + '" > </div>');
$('#Calendar').append(dp);
console.log("Month: "+dateObj.getMonth());
dp.datepicker({defaultDate: dateObj});
}
})();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.