仅用于月份和年份的Jquery日期选择器
我正在做一个日期选择器。我的代码单独运行很好,但当我在整个应用程序中使用它时,它会在日期标签旁边显示空文本框。我创造了一个新的世界。我需要帮助 因为我的整个代码是巨大的,请。以下是我的代码datepicker.js中的一个文件:仅用于月份和年份的Jquery日期选择器,jquery,html,css,datepicker,Jquery,Html,Css,Datepicker,我正在做一个日期选择器。我的代码单独运行很好,但当我在整个应用程序中使用它时,它会在日期标签旁边显示空文本框。我创造了一个新的世界。我需要帮助 因为我的整个代码是巨大的,请。以下是我的代码datepicker.js中的一个文件: $(function () { $('.date-picker').datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true,
$(function () {
$('.date-picker').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'MM yy',
onClose: function (dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
}
});
});
你需要包括这个
<link rel="stylesheet"href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
及
日期
这会奏效的
$(function()
{ $( "#datepicker" ).datepicker({
changeMonth:true,
changeYear:true,
yearRange:"-50:+50",
dateFormat:"yy-mm-dd" });
});
<label>Date</label><input type="text" name="datepicker" id="datepicker"/>