2016-07-16 79 views
1

我想在顯示時向datepicker添加類。我寫了這段代碼但不起作用。數據中心的Onshow事件

該怎麼辦?

$(targetEl).datepicker({ 
     dateFormat: "yy/mm/dd", 
     changeMonth: true, 
     changeYear: true, 
     yearRange: "-100:-13", 
     defaultDate: "-13y", 
     regional: '', 
     isRTL: true, 
     onShow: function() { $("#ui-datepicker-div").addClass("DatePikerEN"); } 

}); 

回答

2

onShow事件文檔中沒有提及。使用beforeShow代替

$('#datepicker').datepicker({ 
     dateFormat: "yy/mm/dd", 
     changeMonth: true, 
     changeYear: true, 
     yearRange: "-100:-13", 
     defaultDate: "-13y", 
     regional: '', 
     isRTL: true, 
     beforeShow: function() { 
      alert('show'); 
      $("#ui-datepicker-div").addClass("DatePikerEN"); 
     } 
}); 

Demo