XDSoft DateTime Picker在jQuery插件中的Onchange事件

On Onchange Event In jQuery Plugins by XDSoft DateTime Picker

本文关键字:Onchange 事件 插件 jQuery DateTime Picker XDSoft      更新时间:2023-09-26

以下是我通过XDSoft DateTime Picker 为jQuery插件中的onchange事件编写的代码

<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>

使用文档中的可用回调

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");
}
 $(function () {
        jQuery('#txtdatetime').datetimepicker({
            startDate: '+1971/05/01',
            format: 'd.m.Y H:i',
            onChangeDateTime: function () {
               //fire what you want
           }
        });
    });