Jquery timepicker插件无法正常工作

时间:2012-06-06 12:35:57

标签: javascript jquery asp.net-mvc-3 datetimepicker timepicker

我在我的视图(JS)中有这个代码:

$("#mydivelement").timepicker();

它不仅仅是timepicker,而是显示datetimepicker。如果重要的话,我在布局页面中设置了datepicker默认值:

$.datepicker.setDefaults({
        dateFormat: 'dd/mm/yy',
        yearRange: '1930:2012',
        changeYear: true,
        changeMonth: true,
        autoSize: true,
        showAnim: 'slideDown',
        firstDay: 1
    });

更新:使用Library-jquery-ui-timepicker-addon.js

1 个答案:

答案 0 :(得分:5)

您错过了将{}添加到.timepicker()

的内部

<强> Jquery的

$(function() {
    $( "#mydivelement" ).datepicker({
     dateFormat: 'dd/mm/yy',
        yearRange: '1930:2012',
        changeYear: true,
        changeMonth: true,
        autoSize: true,
        showAnim: 'slideDown',
        firstDay: 1
    });
    $('#timepicker').timepicker({}); // it shows only timepicker without datepicker
});

jsFiddle example