在XDSoft日期时间选择器的jQuery插件中的Onchange事件

时间:2015-07-06 12:17:49

标签: javascript jquery

以下是我通过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>

2 个答案:

答案 0 :(得分:1)

使用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");
}

答案 1 :(得分:1)

 $(function () {

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