jquery datepicker 选择月份

上官斌
2023-12-01
<script type="text/javascript" charset="utf-8" src="${js}/jquery-1.10.2.min.js"></script> 
<script type="text/javascript" src="${js}/jquery-ui.js"></script>
<script type="text/javascript" src="${js}/jquery.ui.datepicker-zh-TW.js"></script>
<link rel="stylesheet" type="text/css" href="${css }/jquery-ui.css" />
<title>测试页面</title>


<style type="text/css" rel="stylesheet">


 .ui-datepicker table {
   display: none;
 }
 
 #ui-datepicker-div{
    padding-bottom: 5px;
 }
 
</style>


</head>
<body>


  <input type="text" id="testDate"/>
  
<script type="text/javascript">
  $(window).load(function(){
 
 $("#testDate").datepicker({
changeMonth:true,
dateFormat: "yy.mm",
onChangeMonthYear:function(selectedDate){
var selType = $("select").attr("data-handler");
if(selType == 'selectMonth'){
var selectMonth = $("select").children('option:selected').val();
var month = parseInt(selectMonth) + 1;
if(month > 9){
selectedDate = selectedDate + "." + month;
}else{
selectedDate = selectedDate + ".0" + month;
}
$("#testDate").val(selectedDate);
}
$("#ui-datepicker-div").hide();
}
 });  
 
 $("#testDate").click(function(){
 $("#ui-datepicker-div").show();
 });
  });
</script>
</body>
 类似资料: