2015-07-06 35 views
-1

這裏是我的編碼由XDSoft日期時間選取器在OnChange事件在jQuery插件通過XDSoft日期時間選取器

<input type="text" data-format="dd/MM/yyyy hh:mm:ss" class="form-control" id="txtdatetime"> 
<script type="text/javascript"> 
    $(function() {   
    jQuery('#txtdatetime').datetimepicker({ 
    startDate: '+1971/05/01', 
    format: 'd.m.Y H:i', 
    onChangeDateTime: function() { 
    alert('yup'); 
    } 
    }); 
}); 
</script> 

回答

1

使用可用的回調在jQuery插件onchange事件從the doc

onSelectDate: function() {}, 
onSelectTime: function() {}, 
onChangeMonth: function() {}, 
onChangeYear: function() {}, 
onChangeDateTime: function() {}, //the one you're after 
onShow: function() {}, 
onClose: function() {}, 
onGenerate: function() {} 

所以,你的代碼變爲:

$(function() { 
    $('#txtdatetime').datetimepicker({ 
     startDate: '+1971/05/01', 
     format: 'd.m.Y H:i', 
     onChangeDateTime: myfunction 
    }); 
}); 

function myfunction() { 
    alert("yup"); 
} 
+0

謝謝@Ishettyl –

1
$(function() { 

     jQuery('#txtdatetime').datetimepicker({ 
      startDate: '+1971/05/01', 
      format: 'd.m.Y H:i', 
      onChangeDateTime: function() { 
       //fire what you want 
      } 
     }); 
    }); 
+0

謝謝:) coolgyu –

+1

請提供一些解釋,說明你做了什麼以及它爲什麼起作用 – depperm

+0

@depperm ..有一個更改事件onChangeDateTime ..顯然它會在更改日期時觸發 – coolguy

相關問題