首先修改默认日期赋值
<script type="text/javascript">
$(function(){
$('#searchDate').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm',
showButtonPanel: true,
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month option:selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year option:selected").val();
month = parseInt(month)+1;//要对月值加1才是实际的月份
if(month < 10){
month = "0" + month;
}
$('#searchDate').val(year + '-' + month);
}
});
});
</script>
然后隐藏day面板
<style type="text/css">
.ui-datepicker-calendar {display: none;}
</style>